当前位置:网站首页>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
边栏推荐
- 索引:手把手教你索引从零基础到精通使用
- Kubernetes service discovery monitoring endpoints
- 209. Minimum length subarray - sliding window
- 给 el-dialog 增加拖拽功能
- [WPF binding 3] listview basic binding and data template binding
- MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
- Websocket (basic)
- 122. 买卖股票的最佳时机 II-一次遍历
- [related to zhengheyuan cutting tools]
- Allowed latency and side output
猜你喜欢
.Net Core3. 1 use razorengine NETCORE production entity generator (MVC web version)
2021长城杯WP
92. Reverse linked list II byte skipping high frequency question
超分之TDAN
Understanding of RPC core concepts
2021 Great Wall Cup WP
【Appium】通过设计关键字驱动文件来编写脚本
Dry goods | how to extract thumbnails quickly?
嵌入式系统中,FLASH中的程序代码必须搬到RAM中运行吗?
土地覆盖/利用数据产品下载
随机推荐
2.Electron之HelloWorld
Node template engine (EJS, art template)
How to change input into text
C listens for WMI events
Websocket (basic)
How to manually implement the mechanism of triggering garbage collection in node
Kubernetes service discovery monitoring endpoints
Qt error: /usr/bin/ld: cannot find -lGL: No such file or directory
stm32入门开发板选野火还是正点原子呢?
Future usage details
Using quartz under. Net core -- general properties and priority of triggers for [5] jobs and triggers
Use of five routing guards
Indexes and views in MySQL
Use of shell sed command
Compare the performance of query based on the number of paging data that meet the query conditions
開期貨,開戶雲安全還是相信期貨公司的軟件?
SiteServer CMS5. 0 Usage Summary
470. 用 Rand7() 实现 Rand10()
Construction of functions in C language programming
For the space occupation of the software, please refer to the installation directory