zoukankan      html  css  js  c++  java
  • 【JavaScript】之【Object】

    见代码:

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Object</title>
     6 
     7 </head>
     8 <body>
     9 <script type="text/javascript">
    10     //        let obj = {};
    11     //        let arr = [];
    12     var obj = {};
    13     var arr = [];
    14 
    15     console.log(typeof obj);//object
    16     console.log(typeof arr);//object
    17     console.log(typeof null);//object
    18     console.log(typeof '');//string
    19     console.log(typeof undefined);//undefined
    20 
    21     console.log('*******************************************');
    22 
    23     console.log(typeof obj === 'object');//true
    24     console.log(typeof arr === 'object');//true
    25     console.log(typeof null === 'object');//true
    26     console.log(typeof '' === 'object');//false
    27     console.log(typeof undefined === 'object');//false
    28 
    29     console.log('*******************************************');
    30 
    31     console.log("typeof obj === 'object':" + typeof obj === 'object');//false
    32     console.log("typeof arr === 'object':" + typeof arr === 'object');//false
    33     console.log("typeof null === 'object':" + typeof null === 'object');//false
    34     console.log("typeof '' === 'object':" + typeof '' === 'object');//false
    35     console.log("typeof undefined === 'object':" + typeof undefined === 'object');//false
    36 
    37     console.log('------------------优先级搞的鬼');
    38 
    39     console.log("typeof obj === 'object':" + (typeof obj === 'object'));//typeof obj === 'object':true
    40     console.log("typeof arr === 'object':" + (typeof arr === 'object'));//typeof arr === 'object':true
    41     console.log("typeof null === 'object':" + (typeof null === 'object'));//typeof null === 'object':true
    42     console.log("typeof '' === 'object':" + (typeof '' === 'object'));//typeof '' === 'object':false
    43     console.log("typeof undefined === 'object':" + (typeof undefined === 'object'));//typeof undefined === 'object':false
    44 
    45 
    46     console.log('------------------优先级搞的鬼');
    47     console.log(("typeof obj === 'object':" + typeof obj) === 'object');//false
    48     console.log(("typeof arr === 'object':" + typeof arr) === 'object');//false
    49     console.log(("typeof null === 'object':" + typeof null) === 'object');//false
    50     console.log(("typeof '' === 'object':" + typeof '') === 'object');//false
    51     console.log(("typeof undefined === 'object':" + typeof undefined) === 'object');//false
    52     //"typeof obj === 'object':object“ === 'object' --------false
    53 
    54     console.log('*******************************************');
    55 
    56     console.log("Object.prototype.toString.call(obj) === '[object Object]':" + (Object.prototype.toString.call(obj)));//Object.prototype.toString.call(obj) === '[object Object]':[object Object]
    57     console.log("Object.prototype.toString.call(arr) === '[object Object]':" + (Object.prototype.toString.call(arr)));//Object.prototype.toString.call(arr) === '[object Object]':[object Array]
    58     console.log("Object.prototype.toString.call(null) === '[object Object]':" + (Object.prototype.toString.call(null)));//Object.prototype.toString.call(null) === '[object Object]':[object Null]
    59     console.log("Object.prototype.toString.call('') === '[object Object]':" + (Object.prototype.toString.call('')));//Object.prototype.toString.call('') === '[object Object]':[object String]
    60     console.log("Object.prototype.toString.call(undefined) === '[object Object]':" + (Object.prototype.toString.call(undefined)));// Object.prototype.toString.call(undefined) === '[object Object]':[object Undefined]
    61 
    62     console.log('*******************************************');
    63     //严谨的判断Object方式:
    64     console.log("Object.prototype.toString.call(obj) === '[object Object]':" + (Object.prototype.toString.call(obj) === "[object Object]"));//Object.prototype.toString.call(obj) === '[object Object]':true
    65     console.log("Object.prototype.toString.call(arr) === '[object Object]':" + (Object.prototype.toString.call(arr) === "[object Object]"));//Object.prototype.toString.call(arr) === '[object Object]':false
    66     console.log("Object.prototype.toString.call(null) === '[object Object]':" + (Object.prototype.toString.call(null) === "[object Object]"));// Object.prototype.toString.call(null) === '[object Object]':false
    67     console.log("Object.prototype.toString.call('') === '[object Object]':" + (Object.prototype.toString.call('') === "[object Object]"));// Object.prototype.toString.call('') === '[object Object]':false
    68     console.log("Object.prototype.toString.call(undefined) === '[object Object]':" + (Object.prototype.toString.call(undefined) === "[object Object]"));//Object.prototype.toString.call(undefined) === '[object Object]':false
    69 
    70 </script>
    71 </body>
    72 </html>
    View Code
  • 相关阅读:
    使用Xcode 制作自定义storyboard启动界面,供uniAPP使用。
    由于ios由UIWebView换成了WKWebview内核后导致webview请求接口文件上传,后台接收不到文件
    标准基座获取定位可以获取address城市,自定义基座获取不到address
    WeeklyEnglish 2020
    Maven编译打包时报“PKIX path building failed”异常解决方法
    Spring Security
    在IDEA中导入GIT项目
    利用git上传本地文件、文件夹到Github
    OpenAM
    CentOS 安装 OpenAM
  • 原文地址:https://www.cnblogs.com/allearner/p/5058735.html
Copyright © 2011-2022 走看看