会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
是桂
life begins at the end of your comfort zone
博客园
首页
新随笔
联系
管理
订阅
上一页
1
···
4
5
6
7
8
9
10
11
12
···
14
下一页
2020年6月21日
改变this指向&闭包特性
摘要: Q:为什么用普通函数时,setTimeout里面的this指向的是window? //通过保留this的方式,通过闭包的特性去拿this let _this = this //...ajax setTimeout(function(){ _this.age = 14; //console.log(t
阅读全文
posted @ 2020-06-21 00:39 是桂
阅读(139)
评论(0)
推荐(0)
2020年6月20日
ES6扩展——箭头函数
摘要: 1、箭头函数 在es6中,单一参数的单行箭头函数语法结构可以总结如下: const 函数名 = 传入的参数 => 函数返回的内容,因此针对于 const pop = arr => arr.pop(),其中 pop是函数名, arr是传的参数 , =>之后的内容是函数返回的内容,该函数相当于: var
阅读全文
posted @ 2020-06-20 01:20 是桂
阅读(258)
评论(0)
推荐(0)
2020年6月17日
ES6扩展——函数扩展之剩余函数
摘要: 1、结合扩展运算符 //剩余参数是做聚合的,扩展运算符是做展开的 function sum(...args){ console.log(arguments); console.log(arguments instanceof Array); //false 因为它是一个类数组对象 //以下代码均可将
阅读全文
posted @ 2020-06-17 01:34 是桂
阅读(242)
评论(0)
推荐(0)
2020年6月16日
ES6扩展——函数扩展之默认参数
摘要: 1、函数的默认参数 //函数的默认参数 function add(a, b = 999){ console.log(a,b); //1 999 } add(1); 2、 函数的形参可以设置默认值,默认值可以与前一个参数进行相加等运算,但不能和自身或后一个参数进行运算,否则报错; //参数b后面不能出
阅读全文
posted @ 2020-06-16 00:50 是桂
阅读(145)
评论(0)
推荐(0)
2020年6月14日
ES6扩展——数值扩展
摘要: 1.0o代表八进制 0b代表二进制 ,通过Number()可转为10进制; //0o 0O octanary八进制 //0b 0B binary二进制 console.log(0o16); //14 console.log(0b1111); //15 2.parseInt方法从window换到了Nu
阅读全文
posted @ 2020-06-14 00:38 是桂
阅读(307)
评论(1)
推荐(0)
ES6扩展——正则扩展(u、y修饰符)
摘要: //下面三行代码效果一样 //全局匹配开头为a的 const regexp1 = /^a/g; const regexp2 = new RegExp('a','g'); const regexp3 = new RegExp(/^a/); const regexp4 = new RegExp(/a/)
阅读全文
posted @ 2020-06-14 00:32 是桂
阅读(274)
评论(0)
推荐(0)
for-of
摘要: //1、使用for-of遍历字符串.word是要遍历的每一个字符,str是要被遍历的字符串 for(let word of str){ console.log(word); } 2、Array.prototype.slice.call()能将具有length属性的对象转成数组,记住这样使用就可以。
阅读全文
posted @ 2020-06-14 00:29 是桂
阅读(113)
评论(0)
推荐(0)
2020年6月13日
ES6扩展——字符串部分新的方法
摘要: 1、padStart padEnd(count, 字符串) 补全字符串 //padStart(num,str) padEnd补全一个字符串的长度 //num表示补全到几位,str是用来填充的字符串 { let str = 'i'; let str1 = str.padStart(6,'mooc')
阅读全文
posted @ 2020-06-13 23:51 是桂
阅读(212)
评论(0)
推荐(0)
forEach
摘要: forEach也是数组循环的一种方法,如下: array.forEach(function(currentValue, index, arr), thisValue) 如上的array表示的是数组,即数组去调用forEach()方法,方法可以传入两个参数,第一个就是函数。第二个参数(thisValu
阅读全文
posted @ 2020-06-13 23:46 是桂
阅读(342)
评论(0)
推荐(0)
ES6扩展——模板字符串
摘要: ${ } 模板字符串占位符 需要用反引号` ` 1、模板字符串 `${变量}` const xiaoming = { name:'xiaoming', age:14, say1:function(){ console.log('我叫'+ this.name + ',我今年'+this.age +'岁
阅读全文
posted @ 2020-06-13 23:44 是桂
阅读(225)
评论(0)
推荐(0)
上一页
1
···
4
5
6
7
8
9
10
11
12
···
14
下一页
公告