élément de clone js
// Syntax:
let newClone = node.cloneNode([deep])
// Example:
let p = document.getElementById("para1")
let p_prime = p.cloneNode(true)
P. Tune
// Syntax:
let newClone = node.cloneNode([deep])
// Example:
let p = document.getElementById("para1")
let p_prime = p.cloneNode(true)
var x = {myProp: "value"};
var xClone = Object.assign({}, x);
//Obs: nested objects are still copied as reference.
var sheep={"height":20,"name":"Melvin"};
var clonedSheep=JSON.parse(JSON.stringify(sheep));
//note: cloning like this will not work with some complex objects such as: Date(), undefined, Infinity
// For complex objects try: lodash's cloneDeep() method or angularJS angular.copy() method
const target = document.querySelector('div');
const clonedTarget = target.cloneNode();