当前位置:网站首页>Type judgment in [untitled] JS
Type judgment in [untitled] JS
2022-04-23 17:40:00 【Lost Camel】
index.js
/** js The data types are : string, number, boolean, undefined, null, symbel object, array, function */
console.log('-----------Undefined--------')
console.log(undefined == undefined) // true
console.log(undefined === undefined) // true
console.log()
console.log('-----------Null--------')
console.log(null == null) // true
console.log(null === null) // true
console.log()
console.log('-----------String--------')
console.log('name' == 'name') // true
console.log('name' === 'name') // true
console.log()
console.log('-----------Number--------')
console.log(10 == '10') // true
console.log(10 == '010') // true
console.log(10 === '10') // false
console.log(10 === 10) // true
console.log(NaN == NaN) // false
console.log(NaN === NaN) // false
console.log(isNaN(NaN)) // true
console.log()
console.log('-----------Boolean--------')
console.log(true == true) // true
console.log(true === true) // true
console.log('-----------Object--------')
console.log({
} == {
}) // false
console.log({
} === {
}) // false
console.log(typeof {
}) // 'object'
console.log(typeof {
} == 'object') // true
// console.log(Object.isObject({})) // true
console.log('-----------typeof Value ( Unable to judge object, array, null--------')
console.log(typeof '') // 'string'
console.log(typeof 0) // 'number' -------- 111
console.log(typeof true) // 'boolean'
console.log(typeof undefined) // 'undefined'
console.log(typeof null) // 'object' -------- 222
console.log(typeof NaN) // 'number' -------- 111
console.log(typeof {
}) // object --------222
console.log(typeof []) // object --------222
console.log(typeof function () {
}) // function
console.log('-----------Object.prototype.toString.call Value --------')
console.log(Object.prototype.toString.call('')) // '[object String]'
console.log(Object.prototype.toString.call(0)) // '[object Number]'
console.log(Object.prototype.toString.call(true)) // '[object Boolean]'
console.log(Object.prototype.toString.call(undefined)) // '[object Undefined]'
console.log(Object.prototype.toString.call(null)) // '[object Null]'
console.log(Object.prototype.toString.call(NaN)) // '[object Number]'
console.log(Object.prototype.toString.call({
})) // '[object Object]'
console.log(Object.prototype.toString.call([])) // '[object Array]'
console.log(Object.prototype.toString.call(new Function ())) // '[object Function]'
console.log(Object.prototype.toString.call(function (){
})) // '[object Function]'
console.log('-----------if conditional --------')
if (0) {
// Judge not empty
console.log(' if (0) ==> true ')
} else {
console.log(' if (0) ==> false ') // false
}
if ('0') {
console.log(' if ("0") ==> true ') // true
} else {
console.log(' if ("0") ==> false ')
}
if (undefined) {
console.log(' if (undefined) ==> true ')
} else {
console.log(' if (undefined) ==> false ') // false
}
if (null) {
console.log(' if (null) ==> true ')
} else {
console.log(' if (null) ==> false ') // false
}
if ({
}) {
console.log(' if ({}) ==> true ') // true
} else {
console.log(' if ({}) ==> false ')
}
if ([]) {
console.log(' if ([]) ==> true ') // true
} else {
console.log(' if ([]) ==> false ')
}
if (new Function()) {
console.log(' if (new Function()) ==> true ') // true
} else {
console.log(' if (new Function()) ==> false ')
}
/** -----------if conditional -------- if (0) ==> false if ("0") ==> true if (undefined) ==> false if (null) ==> false if ({}) ==> true if ([]) ==> true if (new Function()) ==> true */
版权声明
本文为[Lost Camel]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230552420554.html
边栏推荐
- Understanding of RPC core concepts
- Using quartz under. Net core -- job attributes and exceptions of [4] jobs and triggers
- If you start from zero according to the frame
- tidb-server 的配置文件在哪里?
- 快时钟同步慢时钟域下的异步控制信号slow clk to fast clk
- 122. The best time to buy and sell stocks II - one-time traversal
- Low code development platform sorting
- Some questions some questions some questions some questions
- Shell - introduction, variables, and basic syntax
- 【Appium】通过设计关键字驱动文件来编写脚本
猜你喜欢
随机推荐
Ring back to origin problem - byte jumping high frequency problem
122. 买卖股票的最佳时机 II-一次遍历
PC uses wireless network card to connect to mobile phone hotspot. Why can't you surf the Internet
Using quartz under. Net core -- general properties and priority of triggers for [5] jobs and triggers
Kubernetes service discovery monitoring endpoints
Router object, route object, declarative navigation, programmed navigation
stm32入门开发板选野火还是正点原子呢?
Exercise: even sum, threshold segmentation and difference (two basic questions of list object)
440. 字典序的第K小数字(困难)-字典树-数节点-字节跳动高频题
Double pointer advanced -- leetcode title -- container with the most water
470. Rand10() is implemented with rand7()
Ouvrir des contrats à terme, ouvrir des comptes en nuage ou faire confiance aux logiciels des sociétés à terme?
Solution of Navicat connecting Oracle library is not loaded
Some questions some questions some questions some questions
Use of shell sed command
Clickhouse table engine
Use of shell cut command
[C] thoroughly understand the deep copy
常用SQL语句总结
RPC核心概念理解








