当前位置:网站首页>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
边栏推荐
- Use of shell cut command
- 一些问题一些问题一些问题一些问题
- tidb-server 的配置文件在哪里?
- 01 - get to know the advantages of sketch sketch
- C dapper basically uses addition, deletion, modification and query transactions, etc
- Commonly used functions -- spineros:: and spineros::)
- ASP. Net core JWT certification
- 48. 旋转图像
- Model problems of stock in and stock out and inventory system
- 92. Reverse linked list II byte skipping high frequency question
猜你喜欢
快时钟同步慢时钟域下的异步控制信号slow clk to fast clk
常用SQL语句总结
If you start from zero according to the frame
Halo open source project learning (II): entity classes and data tables
1217_ Generating target files using scons
Simulation of infrared wireless communication based on 51 single chip microcomputer
Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
2021 Great Wall Cup WP
[logical fallacy in life] Scarecrow fallacy and inability to refute are not proof
MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
随机推荐
uni-app黑马优购项目学习记录(下)
41. 缺失的第一个正数
双闭环直流调速系统matlab/simulink仿真
Use of todesk remote control software
Use of shell cut command
Manually implement simple promise and its basic functions
C语言函数详解
402. Remove K digits - greedy
[batch change MySQL table and corresponding codes of fields in the table]
【Appium】通过设计关键字驱动文件来编写脚本
给 el-dialog 增加拖拽功能
For the space occupation of the software, please refer to the installation directory
209. Minimum length subarray - sliding window
Use of shell sed command
In embedded system, must the program code in flash be moved to ram to run?
48. 旋转图像
[logical fallacy in life] Scarecrow fallacy and inability to refute are not proof
Indexes and views in MySQL
嵌入式系统中,FLASH中的程序代码必须搬到RAM中运行吗?
PC电脑使用无线网卡连接上手机热点,为什么不能上网