当前位置:网站首页>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
边栏推荐
- Advantages and disadvantages of several note taking software
- STM32 entry development board choose wildfire or punctual atom?
- 快时钟同步慢时钟域下的异步控制信号slow clk to fast clk
- [simple understanding of database]
- Oninput one function to control multiple oninputs (take the contents of this input box as parameters) [very practical, very practical]
- Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
- Manually implement call, apply and bind functions
- 常用SQL语句总结
- 【Appium】通过设计关键字驱动文件来编写脚本
- 31. 下一个排列
猜你喜欢
Use of todesk remote control software
470. Rand10() is implemented with rand7()
Compare the performance of query based on the number of paging data that meet the query conditions
flink 学习(十二)Allowed Lateness和 Side Output
双闭环直流调速系统matlab/simulink仿真
MySQL进阶之索引【分类,性能分析,使用,设计原则】
[WPF binding 3] listview basic binding and data template binding
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
Advantages and disadvantages of several note taking software
102. Sequence traversal of binary tree
随机推荐
Indexes and views in MySQL
【Appium】通过设计关键字驱动文件来编写脚本
Perception of linear algebra 2
Use of shell awk command
239. 滑动窗口最大值(困难)-单向队列、大顶堆-字节跳动高频题
[C] thoroughly understand the deep copy
为什么有些人说单片机简单,我学起来这么吃力?
Solution of Navicat connecting Oracle library is not loaded
209. 长度最小的子数组-滑动窗口
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
Excel quickly and automatically fills the contents of a row on a blank cell
Use of todesk remote control software
Tdan over half
In ancient Egypt and Greece, what base system was used in mathematics
Using quartz under. Net core -- a simple trigger of [7] operation and trigger
Low code development platform sorting
一些问题一些问题一些问题一些问题
Index: teach you index from zero basis to proficient use
tidb-server 的配置文件在哪里?
440. 字典序的第K小数字(困难)-字典树-数节点-字节跳动高频题