filter等方法的隐式转化
var list = [1,,2,,0,5,9];
console.log(list[1]);
console.log(list[1] !== null);
list = list.filter(item => item !== null);
通过prototype骗过引擎
var proto = {};
var obj = Object.create(proto);
function fn() {};
fn.prototype = proto;
console.log(obj instanceof fn);
浮点数计算问题
0.1 + 0.2 === 0.3
0.1 + 0.05 === 0.15;
0.1 + 0.1 === 0.2;
0.1 + 0.3 === 0.4;
0.2 + 0.2 === 0.4;
0.05 + 0.25 === 0.3;
0.15 + 0.15 === 0.3;
任何操作数与NaN进行关系比较, 结果都为false
"a" < 3;
"a" >= 3;
操作未声明变量
var message;
console.log(message);
console.log(age);
console.log(typeof message);
console.log(typeof age);
console.log(window.message);
console.log(window.age);
console.log打印
var arr = [1, 2];
console.log(arr);
for(var i=0, len = arr.length; i < len; i++) {
arr.shift();
}
自执行函数
+function() {}()
!function() {}()
-function() {}()
(+function(){}())
new function(){}
!function() {return false}()
判断-0
num === -0
Object.is(-0, 0);
Object.is(NaN, NaN);