【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 类型的对 ...
随机推荐
- angularjs自定义过滤器
实现一个按输入框中的数据筛选的功能,筛选可按电影的名称.年份.评分检索框: <input type="text" placeholder="可检索名字评分和年份&q ...
- 公告栏放honehoneclock和喂小老鼠flash
如果你想要放flash在公告栏,像很火的honehoneclock,就要向管理员发邮件申请js权限啦啦啦~~~~~~~Email地址:博客园 <contact@cnblogs.com> 申 ...
- Jquery动态操作checkbox
问题的由来:html页面中使用checkbox给新建用户授权,然后提交到后台服务器,完成给用户授权.用户授权完成之后,如果用户的权限发生改变管理员需要修改多个用户的权限或查看某用户的权限,点击不同的用 ...
- android studio异常关机后出现的问题
使用android studio 时突然卡死. 重启后所有项目都打不开,提示workspace.xml Error:content is not allowed in prolog 打开work ...
- ueditor使用小结
一.简介 ueditor是百度编辑器,官网地址:http://ueditor.baidu.com/website/ 完整的功能演示,可以参考:http://ueditor.baidu.com/webs ...
- Getting Started with JD Edwards EnterpriseOne Interoperability
Overview Every enterprise holds a forest of branched system spread across a number of business uni ...
- 使用AXIS2客户端调用 WEBSERVICE
问题 在调用WEBSERVICE时,可以使用wsdl2java生成java代码,调用接口,这种方法在接口固定的情况下是一种不错的选择,如果需要动态调用接口,那么这样就行不通了. 解决办法 1.直接构建 ...
- mysql数据的行列转换
动态,适用于列不确定情况,第一种: SET @EE=''; SELECT GROUP_CONCAT('SUM(IF(C2=\'',C2,'\'',',C3,0)) AS ',C2)INTO @EE F ...
- WCF传输大数据的设置2
本节主要内容:1.如何读取Binding中的binding元素.2.CustomBinding元素的基本配置.3.代码示例 一.Bingding是由binding元素构成的,可以根据实际需要,进行适当 ...
- sql 生成指定相同数量数据
select *from 表名 ,(SELECT NUMBER FROM master..spt_values WHERE number BETWEEN 1 AND 2 AND TYPE='P' ...