双精度浮点数有多少位?
答案
const x = 0x10;
assert.equal(x, 10)
assert.equal(x, 15)
assert.equal(x, 16)
const x = 0b10;
assert.equal(x, 1)
assert.equal(x, 2)
const x = 4e2;
assert.equal(x, 8)
assert.equal(x, 40)
assert.equal(x, 400)
const x = 4e-2;
assert.equal(x, 0.04)
assert.equal(x, 0.4)
const x = 123.unknownProperty;
会发生什么?
assert.equal(x, undefined)
TypeError
SyntaxError
let x = 0; const result = [++x, x];
assert.deepEqual(result, [0, 0])
assert.deepEqual(result, [1, 1])
assert.deepEqual(result, [0, 1])
assert.deepEqual(result, [1, 0])
let x = 0; const result = [x++, x];
assert.equal(Number(undefined), 0)
assert.equal(Number(undefined), 1)
assert.equal(Number(undefined), NaN)
assert.equal(Number(null), 0)
assert.equal(Number(null), 1)
assert.equal(Number(null), NaN)
assert.equal(Number(false), 0)
assert.equal(Number(false), 1)
assert.equal(Number(false), NaN)
assert.equal(Number(1), 0)
assert.equal(Number(1), 1)
assert.equal(Number(1), NaN)
assert.equal(Number('1'), 0)
assert.equal(Number('1'), 1)
assert.equal(Number('1'), NaN)
assert.equal(Number(''), 0)
assert.equal(Number(''), 1)
assert.equal(Number(''), NaN)
true
assert.ok(NaN === NaN)
assert.ok(typeof NaN === 'number')
assert.ok(Infinity === Infinity)