上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 34 下一页
摘要: 没有this 没有arguments 不能使用new调用 没有super js的精髓在于创建一个函数并将其传递到某个地方, 这样的函数,需要在适合它的上下文中发挥作用,这就是箭头函数的用武之地了。 阅读全文
posted @ 2020-12-18 14:32 李逍遥701 阅读(75) 评论(0) 推荐(0)
摘要: 1 function slow(x) { 2 // 这里可能会有重负载的 CPU 密集型工作 3 alert(`Called with ${x}`); 4 return x; 5 } 6 7 function cachingDecorator(func) { 8 let cache = new Ma 阅读全文
posted @ 2020-12-17 19:05 李逍遥701 阅读(59) 评论(0) 推荐(0)
摘要: 1 let i = 1; 2 setTimeout(function run() { 3 func(i++); 4 setTimeout(run, 100); 5 }, 100); 等待前一次调用完成后再调用。 阅读全文
posted @ 2020-12-17 18:28 李逍遥701 阅读(1509) 评论(0) 推荐(0)
摘要: let timerId = setTimeout(func|code, [delay], [arg1], [arg2], ...) 形参: 函数或代码字符串 延迟时间(默认为零) 即将执行函数需要的参数 如果传入字符串,js会自动创建一个函数。 setTimeout调用时会返回一个定时器标识符,可以 阅读全文
posted @ 2020-12-17 17:43 李逍遥701 阅读(119) 评论(0) 推荐(0)
摘要: 1 let str = ... 动态地接收来自服务器的代码 ... 2 3 let func = new Function(str); 4 func(); 能够接收字符串,再把字符串转换为函数体代码。 阅读全文
posted @ 2020-12-17 17:24 李逍遥701 阅读(177) 评论(0) 推荐(0)
摘要: 内部函数可以访问外部函数中的属性和方法,即使外部函数已经死亡。 所有函数都会通过隐藏的[[Environment]] 属性记住它们被创建时所在的位置。 阅读全文
posted @ 2020-12-17 14:43 李逍遥701 阅读(87) 评论(0) 推荐(0)
摘要: 形参的个数,Rest参数不算。 1 function ask(question, ...handlers) { 2 let isYes = confirm(question); 3 4 for(let handler of handlers) { 5 if (handler.length == 0) 阅读全文
posted @ 2020-12-17 14:36 李逍遥701 阅读(215) 评论(0) 推荐(0)
摘要: Named Function Expression 1 let sayHi=function fname(who) { 2 alert(`hello, ${who}`); 3 }; 1 let sayHi = function fname(who) { 2 if (who) { 3 alert(`H 阅读全文
posted @ 2020-12-17 13:42 李逍遥701 阅读(510) 评论(0) 推荐(0)
摘要: 全局对象包含的变量和方法,可以在任何地方被使用 globalThis Modules是什么? 阅读全文
posted @ 2020-12-17 12:29 李逍遥701 阅读(50) 评论(0) 推荐(0)
摘要: immediately-invoked function expression 函数表达式: let f=function() {...}; 把函数表达式用()括起来,再加一个(): 1 (function() { 2 var message="hello"; 3 alert(message); 4 阅读全文
posted @ 2020-12-17 11:38 李逍遥701 阅读(113) 评论(0) 推荐(0)
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 34 下一页