Home > Web Front-end > JS Tutorial > js deep copy function

js deep copy function

高洛峰
Release: 2017-01-03 16:04:28
Original
1005 people have browsed it

function objectClone(obj,preventName){ 
if((typeof obj)=='object'){ 
var res=(!obj.sort)?{}:[]; 
for(var i in obj){ 
if(i!=preventName) 
res[i]=objectClone(obj[i],preventName); 
} 
return res; 
}else if((typeof obj)=='function'){ 
return (new obj()).constructor; 
} 
return obj; 
}
Copy after login

For more js deep copy function related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template