关于new的过程
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| function Father(name){ this.name=name; } Father.prototype={ getName:function(){ console.log(this.name) } } var son=new Father('张三');
|
关于apply和call的作用
1 2 3 4 5
| var son2={name:"李四"}; son.getName.apply(son2);
|
apply的第二个参数对象只要有length属性就可以了
类数组的定义就是有length属性就可以了
1 . 类数组怎么变成数组
1 2 3 4 5 6 7 8
| var arrayLike={ length:2, name:'张三' } console.log(Array.isArray(arrayLike)) var arrFunc1 = Array.prototype.slice.call(arrayLike); console.log(Array.isArray(arrFunc1))
|