【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 类型的对 ...
随机推荐
- 多线程环境的UI控件属性更新
Winform: public delegate void UpadataTextCallBack(string str,TextBox text); public void UpadtaText(s ...
- Configure Apache Virtual Hosts - CentOS 7
Difficulty: 2Time: 15 minutes Want to host websites on your server? Using Apache? Great. This articl ...
- Sprint1(第二天11.15)
Sprint1(第二天11.15) Sprint1第一阶段 1.类名:软件工程-第一阶段 2.时间:11.14-11.23 3.选题内容:web版-餐厅到店点餐系统 4.团队博客地址: http:// ...
- 百度在线笔试编程测试题(Python):整数分解成素数的积
编程测试题: 输入一个正整数将其分解成素数的乘积,输入格式连续输入m个数,然后将这m个数分别分解,如 输入: 2 10 20 输出: 2 5 2 2 5 Python code: def primes ...
- Oracle 数据库特殊查询总结
1. 查询本节点及本节点以下的所有节点: select * from table1 c start with c.p_id='0000000' connect by prior c.id=c.p_id ...
- 【基本技能篇】>>第3篇《暗时间_指导学习的方法论——心得》
暗时间——指导学习的方法论 ——2016年2月11日 打造自己的核心竞争力:①专业领域技能:②跨领域的技能(解决问题的能力,创新思维,判断与决策能力,表达沟通能力等等):③学习能力,持续学习和思考新知 ...
- box-sizing 属性、min-width属性、max-width属性
1.box-sizing 这个属性是CSS3新增的属性.IE8开始兼容.box-sizing: border-box; border-box,就是边框的这个小盒.这个属性命令,width数值指的是b ...
- node.js+socket.io安装
最近做安卓遇到一个网络包的bug,服务端使用node做的,通讯用socket.io,但是服务端没法调试,没办法,还是自己搭建一个服务器端吧,索性买了阿里云的ecs测试,之前也配置过node+socke ...
- Leetcode 详解(Valid Number)
Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => ...
- Dom4j解析xml
public class Dom4jTest { // Dom4j解析xml // 因为所有的方法都需要Dom树 static Document document = null; static Ele ...