index.js
console.log('-----------Undefined--------')
console.log(undefined == undefined)
console.log(undefined === undefined)
console.log()
console.log('-----------Null--------')
console.log(null == null)
console.log(null === null)
console.log()
console.log('-----------String--------')
console.log('name' == 'name')
console.log('name' === 'name')
console.log()
console.log('-----------Number--------')
console.log(10 == '10')
console.log(10 == '010')
console.log(10 === '10')
console.log(10 === 10)
console.log(NaN == NaN)
console.log(NaN === NaN)
console.log(isNaN(NaN))
console.log()
console.log('-----------Boolean--------')
console.log(true == true)
console.log(true === true)
console.log('-----------Object--------')
console.log({} == {})
console.log({} === {})
console.log(typeof {})
console.log(typeof {} == 'object')
console.log('-----------typeof的值(无法判断 object, array, null--------')
console.log(typeof '')
console.log(typeof 0)
console.log(typeof true)
console.log(typeof undefined)
console.log(typeof null)
console.log(typeof NaN)
console.log(typeof {})
console.log(typeof [])
console.log(typeof function () {})
console.log('-----------Object.prototype.toString.call的值--------')
console.log(Object.prototype.toString.call(''))
console.log(Object.prototype.toString.call(0))
console.log(Object.prototype.toString.call(true))
console.log(Object.prototype.toString.call(undefined))
console.log(Object.prototype.toString.call(null))
console.log(Object.prototype.toString.call(NaN))
console.log(Object.prototype.toString.call({}))
console.log(Object.prototype.toString.call([]))
console.log(Object.prototype.toString.call(new Function ()))
console.log(Object.prototype.toString.call(function (){}))
console.log('-----------if 条件判断--------')
if (0) {
console.log(' if (0) ==> true ')
} else {
console.log(' if (0) ==> false ')
}
if ('0') {
console.log(' if ("0") ==> true ')
} else {
console.log(' if ("0") ==> false ')
}
if (undefined) {
console.log(' if (undefined) ==> true ')
} else {
console.log(' if (undefined) ==> false ')
}
if (null) {
console.log(' if (null) ==> true ')
} else {
console.log(' if (null) ==> false ')
}
if ({}) {
console.log(' if ({}) ==> true ')
} else {
console.log(' if ({}) ==> false ')
}
if ([]) {
console.log(' if ([]) ==> true ')
} else {
console.log(' if ([]) ==> false ')
}
if (new Function()) {
console.log(' if (new Function()) ==> true ')
} else {
console.log(' if (new Function()) ==> false ')
}
|