随笔分类 - es6
摘要:fucntion 谁调用的就指向谁 情况1:如果一个函数中有this,但是它没有被上一级的对象所调用,那么this指向的就是window,这里需要说明的是在js的严格版中this指向的不是window //被上级调用,上级为window function a(){ var user = "追梦子";
阅读全文
摘要:1.写法不一样 //function function fn(a,b){ return a+b } //arrow function var foo = (a,b)=>{ return a+b } 2.this的指向,function中的this可变(window,内部),箭头函数固定不变指向win
阅读全文
摘要:class Foo { static classMethod() { return 'hello'; } } Foo.classMethod() // 'hello' // static方法不能被实例继承 var foo = new Foo(); foo.classMethod() // TypeError: foo.classMethod is not a function ...
阅读全文
摘要:function vie(){ var speed = 100 return { getSpeed: () => speed, speedUp:function(){ speed+=10 } } } console.log(vie().getSpeed()) vie().speedUp() cons
阅读全文
摘要:class Box{ constructor(){ console.log("啦啦啦,今天天气好晴朗");//当实例化对象时该行代码会执行。 } kk(){ console.log(123456) } } var obj=new Box(); obj.kk() js语言中,生成实例对象的传统方法就是通过构造函数: fun...
阅读全文
摘要:includes返回true false indexOf返回-1或者位数
阅读全文
摘要:set 它类似于数组,但是成员的值都是唯一的,没有重复的值。 方法:add(),has(),delete(),clear() 转为对像: const items = new Set([1, 2, 3, 4, 5]);const array = Array.from(items); 去除数组重复成员:
阅读全文
摘要:const arrt=[1,2,3,4]const arrt1=[6,7,8,9]arrt.push(...arrt1) 输入 [1,2,3,4,6,7,8,9] es5写法:Array.prototype.push.apply(arr1, arr2);
阅读全文

浙公网安备 33010602011771号