- 為什么數(shù)組、空字符串可以轉(zhuǎn)為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 函數(shù)擴展那一章說:
原始意圖是返回一個對象{ a: 1 }弛随,但是由于引擎認為大括號是代碼塊,所以執(zhí)行了一行語句a: 1宁赤。這時舀透,a可以被解釋為語句的標(biāo)簽,因此實際執(zhí)行的語句是1;决左,然后函數(shù)就結(jié)束了愕够,沒有返回值
所以冒號:是被人拋棄了嗎?
- 查東東的時候佛猛,莫名其妙看到這個問題:如果讓 (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 指代什么遂跟,是當(dāng)前的對象實例嗎?好像指的就是這個類婴渡,不是實例對象 u.u
360瀏覽器說...可以通過<meta>標(biāo)簽來設(shè)置默認的內(nèi)核...然并卵...不知道啥原因.....
瀏覽器能支持的標(biāo)簽呀幻锁、api呀什么的,跟瀏覽器的內(nèi)核有關(guān)還是與瀏覽器的版本有關(guān)呢边臼?
es6 class 關(guān)于 this 的指向問題
- 好像是我傻逼了越败。相當(dāng)于默認綁定。所以拿不到 this 的值
- 看這個 https://blog.csdn.net/arsaycode/article/details/78810254
Node.js 中 fs.readFile / writeFile 和 fs.createReadStream/writeStream 的區(qū)別
ES6 中 子類繼承父類的問題
class A {}
class B extends A {}
B.__proto__ === A // true
為什么是 proto 屬性指向 A 呢
B 相當(dāng)于一個構(gòu)造函數(shù)硼瓣,那么 B 的 prototype 指向的是什么究飞?B.prototype ?