【JavaScript】之【Object】
见代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Object</title> </head>
<body>
<script type="text/javascript">
// let obj = {};
// let arr = [];
var obj = {};
var arr = []; console.log(typeof obj);//object
console.log(typeof arr);//object
console.log(typeof null);//object
console.log(typeof '');//string
console.log(typeof undefined);//undefined console.log('*******************************************'); console.log(typeof obj === 'object');//true
console.log(typeof arr === 'object');//true
console.log(typeof null === 'object');//true
console.log(typeof '' === 'object');//false
console.log(typeof undefined === 'object');//false console.log('*******************************************'); console.log("typeof obj === 'object':" + typeof obj === 'object');//false
console.log("typeof arr === 'object':" + typeof arr === 'object');//false
console.log("typeof null === 'object':" + typeof null === 'object');//false
console.log("typeof '' === 'object':" + typeof '' === 'object');//false
console.log("typeof undefined === 'object':" + typeof undefined === 'object');//false console.log('------------------优先级搞的鬼'); console.log("typeof obj === 'object':" + (typeof obj === 'object'));//typeof obj === 'object':true
console.log("typeof arr === 'object':" + (typeof arr === 'object'));//typeof arr === 'object':true
console.log("typeof null === 'object':" + (typeof null === 'object'));//typeof null === 'object':true
console.log("typeof '' === 'object':" + (typeof '' === 'object'));//typeof '' === 'object':false
console.log("typeof undefined === 'object':" + (typeof undefined === 'object'));//typeof undefined === 'object':false console.log('------------------优先级搞的鬼');
console.log(("typeof obj === 'object':" + typeof obj) === 'object');//false
console.log(("typeof arr === 'object':" + typeof arr) === 'object');//false
console.log(("typeof null === 'object':" + typeof null) === 'object');//false
console.log(("typeof '' === 'object':" + typeof '') === 'object');//false
console.log(("typeof undefined === 'object':" + typeof undefined) === 'object');//false
//"typeof obj === 'object':object“ === 'object' --------false console.log('*******************************************'); console.log("Object.prototype.toString.call(obj) === '[object Object]':" + (Object.prototype.toString.call(obj)));//Object.prototype.toString.call(obj) === '[object Object]':[object Object]
console.log("Object.prototype.toString.call(arr) === '[object Object]':" + (Object.prototype.toString.call(arr)));//Object.prototype.toString.call(arr) === '[object Object]':[object Array]
console.log("Object.prototype.toString.call(null) === '[object Object]':" + (Object.prototype.toString.call(null)));//Object.prototype.toString.call(null) === '[object Object]':[object Null]
console.log("Object.prototype.toString.call('') === '[object Object]':" + (Object.prototype.toString.call('')));//Object.prototype.toString.call('') === '[object Object]':[object String]
console.log("Object.prototype.toString.call(undefined) === '[object Object]':" + (Object.prototype.toString.call(undefined)));// Object.prototype.toString.call(undefined) === '[object Object]':[object Undefined] console.log('*******************************************');
//严谨的判断Object方式:
console.log("Object.prototype.toString.call(obj) === '[object Object]':" + (Object.prototype.toString.call(obj) === "[object Object]"));//Object.prototype.toString.call(obj) === '[object Object]':true
console.log("Object.prototype.toString.call(arr) === '[object Object]':" + (Object.prototype.toString.call(arr) === "[object Object]"));//Object.prototype.toString.call(arr) === '[object Object]':false
console.log("Object.prototype.toString.call(null) === '[object Object]':" + (Object.prototype.toString.call(null) === "[object Object]"));// Object.prototype.toString.call(null) === '[object Object]':false
console.log("Object.prototype.toString.call('') === '[object Object]':" + (Object.prototype.toString.call('') === "[object Object]"));// Object.prototype.toString.call('') === '[object Object]':false
console.log("Object.prototype.toString.call(undefined) === '[object Object]':" + (Object.prototype.toString.call(undefined) === "[object Object]"));//Object.prototype.toString.call(undefined) === '[object Object]':false </script>
</body>
</html>
【JavaScript】之【Object】的更多相关文章
- 从头开始学JavaScript (十一)——Object类型
原文:从头开始学JavaScript (十一)--Object类型 一.object类型 一个object就是一系列属性的集合,一个属性包含一个名字(属性名)和一个值(属性值). object对于在应 ...
- JavaScript中Object的总结
基于原型继承,动态对象扩展,闭包,JavaScript已经成为当今世界上最灵活和富有表现力的编程语言之一. 这里有一个很重要的概念需要特别指出:在JavaScript中,包括所有的函数,数组,键值对和 ...
- JavaScript之Object拆解
转载烦请注明原文链接: https://github.com/Xing-Chuan/blog/blob/master/JavaScript/JavaScript%E4%B9%8BObject%E6%8 ...
- JavaScript Math Object 数字
JavaScript Math Object Math Object The Math object allows you to perform mathematical tasks. Math is ...
- JavaScript中Object.prototype.toString方法的原理
在JavaScript中,想要判断某个对象值属于哪种内置类型,最靠谱的做法就是通过Object.prototype.toString方法. ? 1 2 var arr = []; console.lo ...
- 【WIP】客户端JavaScript Web Object
创建: 2017/10/11 更新: 2017/10/14 标题加上[WIP],增加[TODO] 更新: 2018/01/22 更改标题 [客户端JavaScript Web Object, UR ...
- JavaScript中object和Object有什么区别
JavaScript中object和Object有什么区别,为什么用typeof检测对象,返回object,而用instanceof 必须要接Object呢 ————————————————————— ...
- javascript nested object merge
javascript nested object merge deep copy Object reference type function namespace(oNamespace, sPacka ...
- Javascript判断object还是list/array的类型(包含javascript的数据类型研究)
前提:先研究javascript中的变量有几种,参考: http://www.w3school.com.cn/js/js_datatypes.asp http://glzaction.iteye.co ...
- javascript的 Object 和 Function
一. javascript 的 内置对象: Object 和 Function javascript所有东西,包括 Function 都是对象 . Array 其实是一个 Function 类型的对 ...
随机推荐
- R语言实战(三)基本图形与基本统计分析
本文对应<R语言实战>第6章:基本图形:第7章:基本统计分析 =============================================================== ...
- git pull提示当前不在某个分支上
$ git pull You are not currently on a branch, so I cannot use any 'branch.<branchname>.merge' ...
- 微信内嵌浏览器sessionid丢失问题,nginx ip_hash将所有请求转发到一台机器
现象微信中打开网页,图形验证码填写后,经常提示错误,即使填写正确也会提示错误,并且是间歇性出现. 系统前期,用户使用主要集中在pc浏览器中,一直没有出现这样的问题.近期有部分用户是在微信中访问的,才出 ...
- C++ 多态、虚函数机制以及虚函数表
1.非virtual函数,调用规则取决于对象的显式类型.例如 A* a = new B(); a->display(); 调用的就是A类中定义的display().和对象本体是B无关系. 2. ...
- ueditor使用小结
一.简介 ueditor是百度编辑器,官网地址:http://ueditor.baidu.com/website/ 完整的功能演示,可以参考:http://ueditor.baidu.com/webs ...
- Xcode真机调试出现The account '***' has no team with ID '***'的解决方案
前段时间,想用真机调试的时候出现 The account '***' has no team with ID '***'的问题, 以前页真机调试过,没有这种情况,于是我登陆开发者中心,进去发现说我的账 ...
- merge,join,concat
merge交集 join并集 concat axis=0 竖着连 axis=1 横着连
- ORACLE 误删除视图恢复
1.使用 dba_views 回退到特定时间段,查看定义 select view_name,text from (select * From dba_views AS OF TIMESTAMP(SYS ...
- PL/SQL设置快捷键
PL/SQL常用的快捷方式: sf= select * from sr=select t.*,t.rowid from t sd = select distinct * from d=delete f ...
- Understanding the Internal Message Buffers of Storm
Understanding the Internal Message Buffers of Storm Jun 21st, 2013 Table of Contents Internal messag ...