- 为什么数组、空字符串可以转为0,而空对象不可以?
var str = ''
var arr = []
var obj = {}
console.log(str == 0) // true
console.log(arr == 0) // true
console.log(obj == 0) // false
- 这段代码为什么不会报错捏。
var x = 2
var b = () => {a: 1}
console.log(b()) // undefined
阮一峰在他的es6 函数扩展那一章说:
原始意图是返回一个对象{ a: 1 },但是由于引擎认为大括号是代码块,所以执行了一行语句a: 1。这时,a可以被解释为语句的标签,因此实际执行的语句是1;,然后函数就结束了,没有返回值
所以冒号:是被人抛弃了吗?
- 查东东的时候,莫名其妙看到这个问题:如果让 (aᅠ== 1 && a == 2 &&ᅠa == 3) 返回true
- 看这里!!http://elevenbeans.github.io/2018/01/23/nothing-is-impossible-for-javascript/
- 秀的我脑壳疼系列 u.u 看来还是我太年轻了
- 先挖个坑,晚点填
// 1.js
function test (x, y) {
let x
}
test()
// 2.js
function test (x, y) {
var x
}
test()
// 3.js
function test (x = 2, y = 2) {
var y
console.log(y); // 2
}
test()
- 然后再看这里
var x = 1
function test (x, y = function () {console.log(x = 2)}) {
var x = 3
y()
console.log(x)
}
test()
console.log(x)
class 里面的 this 指代什么,是当前的对象实例吗?好像指的就是这个类,不是实例对象 u.u
360浏览器说...可以通过<meta>标签来设置默认的内核...然并卵...不知道啥原因.....
浏览器能支持的标签呀、api呀什么的,跟浏览器的内核有关还是与浏览器的版本有关呢?
es6 class 关于 this 的指向问题
- 好像是我傻逼了。相当于默认绑定。所以拿不到 this 的值
- 看这个 https://blog.csdn.net/arsaycode/article/details/78810254
Node.js 中 fs.readFile / writeFile 和 fs.createReadStream/writeStream 的区别
ES6 中 子类继承父类的问题
class A {}
class B extends A {}
B.__proto__ === A // true
为什么是 proto 属性指向 A 呢
B 相当于一个构造函数,那么 B 的 prototype 指向的是什么?B.prototype ?