摘要:
{ let draw=function (count) { // 具体抽奖逻辑 console.log(`剩余${count}次`) } let residue=function* (count){ while (count>0) { count-- yield draw(count) } } le 阅读全文
posted @ 2020-05-01 23:56
老韩哥
阅读(180)
评论(0)
推荐(0)
|
摘要:
{ let draw=function (count) { // 具体抽奖逻辑 console.log(`剩余${count}次`) } let residue=function* (count){ while (count>0) { count-- yield draw(count) } } le 阅读全文
posted @ 2020-05-01 23:56
老韩哥
阅读(180)
评论(0)
推荐(0)
摘要:
{ let arr=['hello','world'] let map=arr[Symbol.iterator]() console.log(map.next()) console.log(map.next()) console.log(map.next())} { let obj={ start: 阅读全文
posted @ 2020-05-01 23:26
老韩哥
阅读(93)
评论(0)
推荐(0)
摘要:
{ // es5 let ajax=function (cb) { console.log('执行') setTimeout(function(){ cb&&cb.call() },1000) } ajax(function(){ console.log('timeout1') })} { let 阅读全文
posted @ 2020-05-01 23:12
老韩哥
阅读(121)
评论(0)
推荐(0)
摘要:
{ //基本定义和生成实例 class Parent{ constructor(name='laohan'){ this.name=name } } let v_parent = new Parent() console.log(v_parent) } { //继承 class Parent{ co 阅读全文
posted @ 2020-05-01 22:14
老韩哥
阅读(114)
评论(0)
推荐(0)
摘要:
{ // Proxy 代理 let obj={ time:'2020-05-01', name:'laohan', _id:123 } let monitor = new Proxy(obj,{ // 拦截对象属性的读取 get(target,key){ return target[key].rep 阅读全文
posted @ 2020-05-01 21:47
老韩哥
阅读(157)
评论(0)
推荐(0)
摘要:
{ // 优先考虑 map set 放弃 array object, 如果对数据要求比较高,数据唯一性 用set //Map 与Array 的对比 增,查,改,删 let map = new Map() let array = [] //增 map.set('a',1) array.push({a: 阅读全文
posted @ 2020-05-01 13:17
老韩哥
阅读(155)
评论(0)
推荐(0)
摘要:
{ // Set WeakSet Map WeakMap let list = new Set() list.add(5) list.add(7) console.log(list) console.log('size',list.size) } { let arr =[1,2,3,4,5] let 阅读全文
posted @ 2020-05-01 12:26
老韩哥
阅读(103)
评论(0)
推荐(0)
摘要:
{ // 概念 提供独一无二的值 a=5 b=5 是不行的 let a1=Symbol() let a2=Symbol() console.log(a1 a2) //a1 a2 false let a3=Symbol.for('a')//a3 key值为a let a4=Symbol.for('a' 阅读全文
posted @ 2020-05-01 11:32
老韩哥
阅读(132)
评论(0)
推荐(0)
摘要:
{ // 简洁表示法 let a=1 let b=2 let es5={ a:a, b:b } let es6={ a,b } console.log(es5,es6) let es5_method={ hello:function(){ console.log('hi') } } let es6_ 阅读全文
posted @ 2020-05-01 11:00
老韩哥
阅读(102)
评论(0)
推荐(0)
摘要:
{ // 默认值后面不能再有没有默认值的变量 function text(x,y = 'world') { console.log('默认值',x,y) } text('hello') text('hello','覆盖') } { let x='test' function test(x,y=x){ 阅读全文
posted @ 2020-05-01 10:36
老韩哥
阅读(77)
评论(0)
推荐(0)
摘要:
<p>ES6</p> <p>老韩</p> <script type="text/javascript"> { let arr=Array.of(3,4,7,9,11) console.log('arr',arr)//[3,4,7,9,11] let empty=Array.of() console. 阅读全文
posted @ 2020-05-01 10:09
老韩哥
阅读(102)
评论(0)
推荐(0)
摘要:
{ //二进制0b开头 不区别大小写 console.log(0b10) //八进制0o console.log(0o10) } { //是不是有尽的 console.log('15',Number.isFinite(15))//true console.log('NaN',Number.isFin 阅读全文
posted @ 2020-05-01 08:29
老韩哥
阅读(95)
评论(0)
推荐(0)
摘要:
{ console.log('a','\u0061') console.log('s','\u20BB7')//0xFFFF 是2个字节,20BB 作为2个字节,7 console.log('s','\u{20BB7}')//用{}包着 } { let s='𠮷' console.log('len 阅读全文
posted @ 2020-05-01 07:52
老韩哥
阅读(113)
评论(0)
推荐(0)
摘要:
// 正则扩展 { // ES5中的写法 let regex = new RegExp('xyz','i')//1.2个参数 字符串,修饰符 let regex2 = new RegExp(/xyz/i)//2.1个参数 正则表达式 console.log(regex.test('xyz123'), 阅读全文
posted @ 2020-05-01 06:48
老韩哥
阅读(116)
评论(0)
推荐(0)
摘要:
{ let a,b,rest [a,b] = [1,2] console.log(a,b) } { let a,b,rest [a,b,...rest] = [1,2,3,4,5,6] console.log(a,b,rest) } { let a,b ({a,b} = {a:1,b:2}) con 阅读全文
posted @ 2020-05-01 00:39
老韩哥
阅读(122)
评论(0)
推荐(0)
摘要:
let:块作用域,强制开启严格模式,不可重名 const:块作用域,不可修改(对象是可以的const k ={a:1};k.b=3),必需赋值 function test(){ for(let i = 1,i<5,i++){ console.log(i) } console.log(i)//会报引用 阅读全文
posted @ 2020-05-01 00:10
老韩哥
阅读(98)
评论(0)
推荐(0)
|