Closed Package
Understanding:The A function executes and return the b function and the b function can access a The data for the function
Benefit: The child function is stored inside the complex function, and the child function is not automatically destroyed after execution
Cons: Large memory footprint
Ex
function Bibao () { var i=10; return function () { console.log (i); return i++;} } var bibao_task=Bibao (); Bibao_task (); Bibao_task (); Bibao_task ();
Recursive
Understanding: Child elements have child elements, child elements have child elements .....
Deep copy and shallow copy
Understanding: The difference between human cloning and shadow, memory address
Deep Copy:
Json Functions
Target=json.parse (json.stringify (obj))
$.extend of Jq
$.extend (true, target,obj)//parameter is true for deep copy, otherwise shallow copy
Recursive deep copy
varChina ={Nation:China, birthplaces:{name:' Chen ' }}//For deep replication, recursion is required to achievevarNewc={};functionCopy (CHINA,NEWC) { for(IinchChina ) { if(typeofchina[i]=== ' object ') {Newc[i]=China[i]; Copy (China[i],newc[i])}Else{Newc[i]=China[i]}}} Copy (CHINA,NEWC); Console.log (NEWC)
JavaScript closures, recursive, deep copy