Choi Yang

Results 55 comments of Choi Yang

## new 运算符操作过程 当一个函数被使用 `new` 运算符执行时,它按照以下步骤: 一个新的空对象被创建并分配给 `this`。 函数体执行。通常它会修改 ` this`,为其添加新的属性。 返回 this 的值。 以下面 User 方法为例: ```javascript function User(name) { // this = {};(隐式创建) // 添加属性到 this this.name =...

``` function curry(fn, args = []) { return function(){ let rest = [...args, ...arguments]; if (rest.length < fn.length) { return curry.call(this,fn,rest); }else{ return fn.apply(this,rest); } } } //test function sum(a,b,c)...

掌握盒子水平垂直居中的五大方案 ```javascript Document html,body{ height: 100%; overflow: hidden; } .box{ box-sizing: border-box; width: 100px; height: 50px; line-height: 48px; text-align: center; font-size: 16px; border: 1px solid lightblue; background: lightblue; } /*定位1...

https://segmentfault.com/a/1190000021231422

https://www.zhangxinxu.com/wordpress/2018/04/known-es6-symbol-function/

## 浅拷贝 ### Object.assign() 语法:`Object.assign(target, ...sources)` ES6中拷贝对象的方法,接受的第一个参数是拷贝的目标 `target` ,剩下的参数是拷贝的源对象 `sources`(可以是多个)。 >详细介绍,可以阅读文档《MDN Object.assign》。 ```javascript let obj = { name: 'Chocolate', score: { web: 99, math: 100 } } let newObj =...

## 深拷贝 复制变量值,对于引用数据,则递归至基本类型后,再复制。深拷贝后的对象「与原来的对象完全隔离」,互不影响,对一个对象的修改并不会影响另一个对象。 ### JSON.parse(JSON.stringify()) 其原理是把一个对象序列化成为一个 `JSON` 字符串,将对象的内容转换成字符串的形式再保存在磁盘上,再用 `JSON.parse()` 反序列化将 `JSON` 字符串变成一个新的对象。 ```javascript let user = { name: "leo", skill: { JavaScript: 90, CSS: 80}}; let leo = JSON.parse(JSON.stringify(user)); leo.name...

![image](https://user-images.githubusercontent.com/61035508/105566593-ee8a7c80-5d67-11eb-8858-d9df6d3ea85d.png)

https://juejin.cn/post/6881241853258104839

![image](https://user-images.githubusercontent.com/61035508/105458324-4cb15400-5cc3-11eb-819b-ee6f1b624da7.png)