随笔分类 -  ES6+

摘要:1.Class的用法 class Person{ constructor(name, age){ this.name = name; this.age = age; } say(words){ console.log(`${this.name} is saying ${words}.`); } } 阅读全文
posted @ 2021-02-10 11:12 #Friday 阅读(123) 评论(0) 推荐(0)
摘要:1.只会拷贝本身的属性,不会拷贝prototype上的属性 2.如果有同名的属性,后面的会覆盖前面的 3.target如果不是对象,是string,number或者boolean,会先转化为包装类 4.如果target是undefined,null,无法转化为包装类,那么报错 5.如果source不 阅读全文
posted @ 2021-01-24 14:59 #Friday 阅读(105) 评论(0) 推荐(0)
摘要:let obj = { a: 25 }; function f(a, b){ console.log(this.a , a, b); } f.call(obj, 1, 2); f.apply(obj, [1, 2]); f.bind(obj)(1, 2); 运行结果 阅读全文
posted @ 2021-01-21 22:38 #Friday 阅读(89) 评论(0) 推荐(0)
摘要:// 1.有且只有一个参数,且只有一句返回 let f2 = a => a + 1; console.log(f2(5)); 返回结果 // 2.没有参数,且只有一句返回 let f2 = () => 25; console.log(f2()); 返回结果 // 3.多于一个参数,且只有一句返回 l 阅读全文
posted @ 2021-01-17 20:02 #Friday 阅读(137) 评论(0) 推荐(0)
摘要:字符串模板:支持多行,无需换行;支持使用变量;支持任何的函数表达式 let [a, b, c] = [1, 2, 3]; function f(){ return 15; } let s = `<ul> <li>${f()}</li> <li>${a+b}</li> <li>${c}</li> </ 阅读全文
posted @ 2021-01-17 16:05 #Friday 阅读(128) 评论(0) 推荐(0)
摘要:1.let关键字声明的变量,只在块中有效 if(true){ var a = 5; let b = 5; } console.log(a); console.log(b); 分割线 运行结果: 2.let关键字可以防止循环变量的泄露,同时能够提供闭包 for(let i = 0; i < 5; i+ 阅读全文
posted @ 2021-01-11 22:27 #Friday 阅读(133) 评论(0) 推荐(0)
摘要:第一种:浏览器直接显示(Babel浏览器脚本) <head> <script src="https://cdn.bootcdn.net/ajax/libs/babel-standalone/6.26.0/babel.js" type="text/javascript"></script> <!--  阅读全文
posted @ 2021-01-10 18:14 #Friday 阅读(1828) 评论(0) 推荐(0)
摘要:ES6中写法: <body> <script type="text/babel"> ... </script> </body> 分割线 如果浏览器天然支持ES6的话,也可以写成如下: <body> <script type="module"> ... </script> </body> 分割线 ES 阅读全文
posted @ 2021-01-07 21:45 #Friday 阅读(331) 评论(0) 推荐(0)
摘要:网址: https://www.bootcdn.cn/babel-standalone/ 找到对应版本,点击【复制<script>标签】或者【复制链接】即可: 阅读全文
posted @ 2021-01-06 23:34 #Friday 阅读(469) 评论(0) 推荐(0)