美文网首页
前端资料

前端资料

作者: 给我小前端 | 来源:发表于2018-10-28 11:22 被阅读5次

ES6新数据类型 Symbol .

js变量提升函数提升

js this

js 原型及原型链理解

new做了什么

let obj={};
obj.proto=构造函数.prototype;
构造函数.call(obj);
return obj;

深拷贝浅拷贝.

第一种 递归调用

function copy( sourceObj , c) {
var c = c || ( Array.isArray(sourceObj) ? [ ] : {} );
for (var i in sourceObj) {
if (typeof sourceObj[i] === 'object') {
c[i] = Array.isArray(sourceObj[i]) ? [] : {};
copy (sourceObj[i], c[i]);
} else {
c[i] = sourceObj[i];
}
}
return c;
}
var arrayA = [1,2,3,4,5];
var obj = {name:'Alex'};
arrayA.push(obj)
var arrayB = [];
copy(arrayA,arrayB);
arrayB[5].name = 'Tom'
console.log(arrayA);// [1, 2, 3, 4, 5, "Alex"]
console.log(arrayB);// [1, 2, 3, 4, 5, "Tom"]

第二种 JSON对象的parse和stringify

function deepClone(obj){
let _obj = JSON.stringify(obj),
objClone = JSON.parse(_obj);
return objClone
}
let a=[0,1,[2,3],4],
b=deepClone(a);
a[0]=1;
a[2][0]=1;
console.log(a,b);

第三种 JQ的extend方法

$.extend( [deep ], target, object1 [, objectN ] )

deep表示是否深拷贝,为true为深拷贝,为false,则为浅拷贝

target Object类型 目标对象,其他对象的成员属性将被附加到该对象上。

object1 objectN可选。 Object类型 第一个以及第N个被合并的对象。

let a=[0,1,[2,3],4],
b=$.extend(true,[],a);
a[0]=1;
a[2][0]=1;
console.log(a,b);

相关文章

  • 前端资料

    ES6新数据类型 Symbol . js变量提升函数提升 js this js 原型及原型链理解 new做了什么 ...

  • 前端文章- 收藏集 - 掘金

    GitHub 上学习前端开发的资料(不定期更新) - 前端 - 掘金GitHub 上学习前端开发的资料(不定期更新...

  • javascript中apply 和 call 的区别

    欢迎加入前端交流群来获取视频资料以及前端学习资料:749539640 apply 和 call 的区别 ECMAS...

  • cordova+vue-cli4构建app

    欢迎加入前端交流群来获取视频资料以及前端学习资料:749539640 * 本文会详细的介绍如何使用cordova来...

  • 前端学习资料

    angular学习: 1:英雄指南 2:freecodecamp 2.1:freecodecamp-1 2.2...

  • 前端学习资料

    做前端好几年了,换了两次电脑,每个电脑的浏览器都有密密麻麻的书签,以下是我的记录。 一、vue 1、vue 可...

  • 前端资料分享

    由来: 整理、记录整理日常收集的前端资料 方便大家有效查阅自己需要的东西具体可参考 >Javascript部分 ①...

  • 前端学习资料

    前端 Html+CSS+JS Web前端开发之HTML+CSS精英课堂【渡一教育】 Web前端开发之JavaScr...

  • 大前端资料

    hYrEu 密码:ddci 16.React链接: https://pan.baidu.com/s/1nwnrQx...

  • 前端学习资料

    之前收藏的一些前端网页。 1.学习网站 前端技术w3school作为一个有所沉淀的前端,如何构建自己的前端知识体系...

网友评论

      本文标题:前端资料

      本文链接:https://www.haomeiwen.com/subject/bqlptqtx.html