Fork me on github
上一页 1 2 3 4 5 6 7 8 9 10 ··· 19 下一页
摘要: const myObject = { foo: 'hello', func: function () { const self = this console.log(1, this.foo) console.log(2, self.foo) function a() { console.log(3, 阅读全文
posted @ 2023-06-15 21:18 zjy4fun 阅读(35) 评论(0) 推荐(0) 编辑
摘要: Promise.resolve 静态方法将给定值“解析”为 Promise。 如果值是 Promise,则返回该 Promise;如果值是 thenable,返回的 Promise 会“跟随”这个 thanable 的对象,采用它的最终状态;否则,返回的 promise 将以此值完成。 此函数将类 阅读全文
posted @ 2023-06-15 21:04 zjy4fun 阅读(1069) 评论(0) 推荐(0) 编辑
摘要: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <script> function func1() { console.log(1, this.val 阅读全文
posted @ 2023-06-15 20:38 zjy4fun 阅读(4) 评论(0) 推荐(0) 编辑
摘要: function change(obj) { with(obj) { color = 'red' } } var box = { size: '15*15' } change(box); console.log(color);//red with 代码块内部,每个变量首先会指向 obj 对象属性,所 阅读全文
posted @ 2023-06-14 22:22 zjy4fun 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 下面代码的输出结果: var obj = { brand: 'apple', price: 5999 } Object.defineProperty(obj, 'id', {value: 1}) Object.defineProperty(obj, 'price', {configurable: f 阅读全文
posted @ 2023-06-14 22:13 zjy4fun 阅读(6) 评论(0) 推荐(0) 编辑
摘要: var test = 1.2 console.log(typeof test 'float');// false console.log(typeof test) // number var test2 = '4399' - 0 console.log(typeof test2 'number') 阅读全文
posted @ 2023-06-14 21:55 zjy4fun 阅读(7) 评论(0) 推荐(0) 编辑
摘要: /** * && 运算,如果前面值为true,则结果为后面的值。如果前面值为false,则值为前值. * || 运算,如果前面值为true,则结果为前面的值,如果前面的值为false,则结果为后面的值。 */ console.log(1&&2);//2 console.log(2&&1);//1 c 阅读全文
posted @ 2023-06-14 21:46 zjy4fun 阅读(68) 评论(0) 推荐(0) 编辑
摘要: 在 JavaScript 中,每个对象都有一个原型(prototype)属性,它指向另一个对象。 对象可以继承其原型对象的属性和方法。原型是 JavaScript 实现对象继承的基础概念之一,而原型链则是一种通过多层级原型连接起来的机制。 每个 JavaScript 对象(除了 null 和 und 阅读全文
posted @ 2023-06-14 21:25 zjy4fun 阅读(16) 评论(0) 推荐(0) 编辑
摘要: Function() 构造函数创建了一个新的 Function 对象,直接调用构造函数可以动态创建函数,与eval(可能访问到本地作用域)不同的是, Function 构造函数只创建全局执行的函数。 const sum = new Function('a', 'b', 'return a + b') 阅读全文
posted @ 2023-06-14 21:00 zjy4fun 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 答案是 n1 n2 p1 p2 原因:node中的微任务包含两部分: 1. process.nextTick() 注册的回调 ( nextTick task queue ) 2. promise.then() 注册的回调 ( promise task queue) node在执行微任务时,会优先执行 阅读全文
posted @ 2023-06-14 20:49 zjy4fun 阅读(7) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 19 下一页