typeof 123 // 返回 "number"
typeof "Hello World" // 返回 "string"
typeof true // 返回 "boolean"
typeof undefined // 返回 "undefined"
typeof null // 返回 "object"
typeof [1, 2, 3] // 返回 "object"
typeof {"name": "小米", "age": 32} // 返回 "object"
typeof function() {} // 返回 "function"Object.prototype.toString.call(123) // 返回 "[object Number]"
Object.prototype.toString.call("Hello World") // 返回 "[object String]"
Object.prototype.toString.call(true) // 返回 "[object Boolean]"
Object.prototype.toString.call(undefined) // 返回 "[object Undefined]"
Object.prototype.toString.call(null) // 返回 "[object Null]"
Object.prototype.toString.call([1, 2, 3]) // 返回 "[object Array]"
Object.prototype.toString.call({"name": "小米", "age": 32}) // 返回 "[object Object]"
Object.prototype.toString.call(function() {}) // 返回 "[object Function]"
var arr = [1, 2, 3];
console.log(arr instanceof Array); // 返回 true
var obj = {"name": "小米", "age": 22};
console.log(obj instanceof Object); // 返回 true
function Person(name, age) {
this.name = name;
this.age = age;
}
var alex = new Person("小米", 32);
console.log(alex instanceof Person); // 返回 true
var arr = [1, 2, 3];
console.log(arr.constructor === Array); // 返回 true
var obj = {"name": "小米", "age": 18};
console.log(obj.constructor === Object); // 返回 true
function Person(name, age) {
this.name = name;
this.age = age;
}
var alex = new Person("小米", 18);
console.log(alex.constructor === Person); // 返回 true
PouchDB:一款基于JavaScript 的开源NoSQL文档数据库
JavaScript获取指定网站状态码查询代码(2种实现方法)
上面是“如何利用js语法判断数据类型”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4791.html
workflows工作流
一个极其美丽细致的女孩ComfyUI工作流
1个可爱的白色短发女孩
一个漂亮的混血女孩ComfyUI工作流
严寒的冬天里一只小鸟在森林的树枝上休息
一只蚊子被嵌在琥珀中ComfyUI工作流
一个质朴的木制窗户上放着各种葫芦、南瓜等
一只可爱的快乐老鼠戴着帽子ComfyUI工作流
懂王特朗普3d漫画ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

面试题:js如何设置对象,不能给这个对象添加或者删除属性
















