
ES6
ES6
这个作者很懒,什么都没留下…
展开
-
严格模式
一、开启严格模式 1、为整个脚本(script标签)开启严格模式<script> 'use strict'; // 下面的js 代码就会按照严格模式执行代码</script>//在立即执行函数中<script> (function() { 'use strict'; })();</script> 2、为某个函数开启严格模式...原创 2020-10-02 14:21:50 · 132 阅读 · 0 评论 -
ES6新增数组方法
1、遍历数组 forEacharr.forEach(function(value,index,arr){})2、筛选数组 filter 返回一个新数组varnewArr=arr.filter(function(value,index){ returnvalue>=20;});3、some检测数组中是否有满足条件的元素var arr = [10, 30, 4]; var flag = arr.some(fu...原创 2020-10-02 13:32:26 · 170 阅读 · 0 评论 -
改变this指向---call(),apply()
1、调用函数fn.call();2、改变this指向 call(thisArg,x1,x2)thisArg this要指向谁x1,x2传递的参数(可选,没有就不写)调用fn函数,并且把this指向o function fn(x, y) { console.log('我想喝手磨咖啡'); console.log(this); console.log(x + y); } ...原创 2020-10-02 13:21:15 · 207 阅读 · 0 评论 -
原型对象,对象原型,原型链
1、原型(原型对象)创建函数的方式有一种为构造函数进行创建//利用构造函数创建对象 function Star(uname, age) { this.uname = uname; this.age = age; this.sing = function() { console.log('我会唱歌'); } } var l原创 2020-10-02 11:13:01 · 883 阅读 · 0 评论