JavaScript Array contrast

JavaScript Array contrast

先看起因

前提

a = []

过程

if (a === []) {
    console.log("run this script.");
}

结论

不会输出任何语句

修正

if(a.length === 0) {
	console.log("That is right.");  
}
That is right.

总结

JS的特性,我也会记不住。一般选择最稳妥的方式去写。”

​ – 公司里一位Node开发的前辈

刚刚上手Node,路漫漫其修远兮,吾将上下而求索。加油!

原文地址:https://www.cnblogs.com/l1ng14/p/14726190.html