<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> var aaa = {} aaa.q111 = '1111' console.log(aaa); const bbb = {} bbb.q111 = '1111' console.log(bbb); function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return (false); } var obj = { name: "abc", age: 123, card: ['visa', 'master'], wife: { name: 'bcd', son: { name: 'aaa' } } } console.log(obj) var obj1 = obj; obj1.fff = "2222" console.log(obj1); var obj1 = { } //深度拷贝 function deepClone(origin, target) { var target = target || {}, toStr = Object.prototype.toString, arrStr = "[object Array]"; for (var prop in origin) { if (origin.hasOwnProperty(prop)) { if (origin[prop] !== "null" && typeof(origin[prop]) == 'object') { // if (toStr.call(origin[prop]) == arrStr) { // target[prop] = []; // } else { // target[prop] = {}; // } target[prop] = toStr.call(origin[prop]) == arrStr ? [] : {}; deepClone(origin[prop], target[prop]); } else { target[prop] = origin[prop]; } } } return target; } deepClone(obj, obj1); console.log(obj1) </script> </body> </html>
1、URL解析:正则或字符串分割
2、值和引用:地址
3、拷贝:递归、取值赋值
4、Multipolygon、polygon
5、leaflet-geojson:图层顺序,拷贝数据附加