{"id":3217,"date":"2019-06-24T19:06:39","date_gmt":"2019-06-24T11:06:39","guid":{"rendered":"http:\/\/www.daliane.com\/?p=3217"},"modified":"2019-06-24T19:06:43","modified_gmt":"2019-06-24T11:06:43","slug":"javascript_qi_zhong_shu_ju_lei_xing","status":"publish","type":"post","link":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/javascript_qi_zhong_shu_ju_lei_xing\/","title":{"rendered":"JavaScript \u4e03\u79cd\u6570\u636e\u7c7b\u578b"},"content":{"rendered":"<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<p>\n\t\t\u8bf4\u5230JavaScript\u91cc\u7684\u7c7b\u578b\u5f88\u5bb9\u6613\u5c31\u8ba9\u4eba\u60f3\u8d77 42\u548c&#8221;42&#8243;\uff0c\u5206\u522b\u662fstring\u578b\u548cnumber\u578b\uff0c\u4f46\u662f\u4ed6\u4eec\u53ef\u4ee5\u76f4\u63a5\u8fdb\u884c\u8fd0\u7b97\u3002\u8fd9\u5c31\u662fJs\u91cc\u9762\u6709\u8da3\u53c8\u8ba9\u4eba\u5934\u75bc\u7684\u95ee\u9898\u4e86\u3002JavaScript\u4f1a\u8fdb\u884c\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362\n\t<\/p>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<h3 style=\"font-size:16px;font-weight:400;\">\n\t\t\u4e0b\u9762\u6211\u4eec\u5c31\u6b63\u5f0f\u6765\u8ba4\u8bc6\u4e00\u4e0bJS\u4e2d\u7684\u7c7b\u578b\u5427\uff1a<br \/>\n\t<\/h3>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<h3 style=\"font-size:16px;font-weight:400;\">\n\t\t1\u3001\u5185\u7f6e\u7c7b\u578b<br \/>\n\t<\/h3>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<p>\n\t\tJavaScript\u6709\u4e03\u79cd\u5185\u7f6e\u7c7b\u578b:<br \/>\n<img decoding=\"async\" src=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2019\/06\/5c3bfc810001410b06710507.png\" alt=\"\u56fe\u7247\u63cf\u8ff0\" class=\"\" \/>\n\t<\/p>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<h3 style=\"font-size:16px;font-weight:400;\">\n\t\t2\u3001\u7c7b\u578b\u68c0\u6d4b typeof<br \/>\n\t<\/h3>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<pre>1 typeof undefined === 'undefined';\/\/true\r\n2 typeof 'abc' === 'string';\/\/true\r\n3 typeof 123 === 'number';\/\/true\r\n4 typeof true === 'boolean';\/\/true\r\n5 typeof {a:'test'} === 'object';\/\/true\r\n6 typeof Symbol() === 'symbol';\/\/true<\/pre>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<p>\n\t\t\u4e00\u5171\u4e03\u79cd\u7c7b\u578b\uff0c\u516d\u79cd\u90fd\u5728\u4e0a\u9762\u4e86\uff0c\u8fd8\u6709\u8c01\u5462\uff1f\u5bf9\uff0c\u8fd8\u6709null\u3002<br \/>\nnull \u6bd4\u8f83\u7279\u6b8a\uff0c\u7528typeof \u5224\u65ad\u4f1a\u51fa\u95ee\u9898\n\t<\/p>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<pre>typeof null === 'object';\/\/true<\/pre>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<p>\n\t\t\u7167\u7406\u8bf4\u5e94\u8be5\u662ftypeof null \u7684\u8fd4\u56de\u503c\u5e94\u8be5\u662f\u2019null\u2019\uff0c\u4f46\u662f\u8fd9\u4e2abug\u786e\u5b9e\u5728js\u8bed\u8a00\u4e2d\u5ba2\u89c2\u5b58\u5728\u3002<br \/>\n\u5982\u679c\u8981\u5224\u65ad\u4e00\u4e2a\u503c\u662f\u5426\u662fnull\uff0c\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u8fd9\u79cd\u65b9\u5f0f\u6765\u68c0\u6d4b\uff1a\n\t<\/p>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<pre>var a = null;\r\n if(!a&amp;&amp;typeof a === 'object'){\r\n     \/\/\u6b64\u523b\u8bf4\u660ea\u7684\u503c\u662fnull\r\n     \r\n }<\/pre>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<p>\n\t\tnull\u662f\u201c\u5047\u503c\u201d\uff0c\u4e5f\u662f\u552f\u4e00\u4e00\u4e2a\u7528typeof\u68c0\u6d4b\u4f1a\u8fd4\u56de\u2018object\u2019\u7684\u57fa\u672c\u7c7b\u578b\u503c\u3002<br \/>\n\u53e6\u4e24\u79cd\u7279\u6b8a\u60c5\u51b5\u662ffunction\u548carray\n\t<\/p>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<pre>typeof function a(){} === 'function';\/\/true\r\ntypeof [1,2,3] === 'object';\/\/object<\/pre>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<blockquote>\n<p>\n\t\t\t\u51fd\u6570\u548c\u6570\u7ec4\u90fd\u662f\u5bf9\u8c61\u7684\u5185\u7f6e\u7c7b\u578b\uff0c\u7b97\u662fobject\u7684\u2018\u5b50\u7c7b\u578b\u2019\u3002<br \/>\n\u51fd\u6570\u53ef\u4ee5\u62e5\u6709\u5c5e\u6027\uff0c\u4f8b\u5982a.length;\/\/0;\n\t\t<\/p>\n<\/blockquote>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<h3 style=\"font-size:16px;font-weight:400;\">\n\t\t2\u3001\u503c\u548c\u7c7b\u578b<br \/>\n\t<\/h3>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<blockquote>\n<p>\n\t\t\tJavaScritp\u4e2d\u7684\u53d8\u91cf\u662f\u6ca1\u6709\u7c7b\u578b\u7684\uff0c\u53ea\u6709\u503c\u624d\u6709\u3002\u53d8\u91cf\u53ef\u4ee5\u968f\u65f6\u6301\u6709\u4efb\u4f55\u7c7b\u578b\u7684\u503c<br \/>\n\u8bed\u8a00\u5f15\u64ce\u4e0d\u8981\u6c42\u53d8\u91cf\u603b\u662f\u6301\u6709\u4e0e\u5176\u521d\u59cb\u503c\u540c\u7c7b\u578b\u7684\u503c\u3002\u4e00\u4e2a\u53d8\u91cf\u53ef\u4ee5\u5148\u88ab\u8d4b\u503c\u4e3a\u5b57\u7b26\u4e32\u540e\u91cd\u65b0\u8d4b\u503c\u4e3a\u6570\u5b57\uff0c\u4e0d\u4f1a\u62a5\u9519\u3002\n\t\t<\/p>\n<\/blockquote>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<h3 style=\"font-size:16px;font-weight:400;\">\n\t\t3\u3001undefined\u548cundeclared<br \/>\n\t<\/h3>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<blockquote>\n<p>\n\t\t\t\u53d8\u91cf\u5728\u672a\u6301\u6709\u503c\u7684\u65f6\u5019\u4e3aundefined\uff0c\u6b64\u65f6typeof \u8fd4\u56de \u2019 undefined &#8216;;<br \/>\n\u5df2\u5728\u4f5c\u7528\u57df\u4e2d\u58f0\u660e\u4f46\u6ca1\u6709\u8d4b\u503c\u7684\u53d8\u91cf\u8fd4\u56de\u503c\u662fundefined\uff0c\u5728\u4f5c\u7528\u57df\u4e2d\u6ca1\u58f0\u660e\u8fc7\u7684\u53d8\u91cf\u8fd4\u56de\u503c\u662f\uff1aReferenceError: \u53d8\u91cf\u540d is not defined\n\t\t<\/p>\n<\/blockquote>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<pre>var a ;\r\n a;\/\/undefined\r\n b;\/\/ReferenceError : b is not defined<\/pre>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<blockquote>\n<p>\n\t\t\t\u8fd9\u91cc\u6709\u4e00\u4e2a\u8981\u6ce8\u610f\u7684\u70b9\uff1atypeof \u5bf9\u4e8e\u672a\u58f0\u660e\u8fc7\u548c\u58f0\u660e\u8fc7\u672a\u8d4b\u503c\u7684\u53d8\u91cf\u8fd4\u56de\u7ed3\u679c\u90fd\u662f\u2018undefined\u2019\n\t\t<\/p>\n<\/blockquote>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<h3 style=\"font-size:16px;font-weight:400;\">\n\t\t4\u3001\u5982\u4f55\u5728\u7a0b\u5e8f\u4e2d\u68c0\u67e5\u53d8\u91cf\u662f\u5426\u5df2\u5b58\u5728<br \/>\n\t<\/h3>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<pre>if(typeof myTest !== 'undefined'){\r\n    console.log('myTest\u5df2\u7ecf\u5b58\u5728')\r\n}\r\nif(typeof atob === 'undefined'){\r\n    atob = function(){}\r\n}<\/pre>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<p>\n\t\t\u8fd8\u53ef\u4ee5\u7528\u2018\u4f9d\u8d56\u6ce8\u5165\u2019\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5c31\u662f\u5c06\u4f9d\u8d56\u901a\u8fc7\u53c2\u6570\u663e\u793a\u5730\u4f20\u9012\u5230\u51fd\u6570\u4e2d\uff1a\n\t<\/p>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<pre>function doSomethingCool(FeatureXyz){\r\n    var helper = FeatureXyz || function(){}\r\n    var val = helper();\r\n}<\/pre>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<h3 style=\"font-size:16px;font-weight:400;\">\n\t\t5\u3001\u603b\u7ed3\uff1a<br \/>\n\t<\/h3>\n<\/div>\n<div class=\"cl-preview-section\" style=\"margin:0px;padding:0px;color:#1C1F21;font-family:&quot;font-size:14px;background-color:#F8FAFC;\">\n<p>\n\t\t1\u3001JavaScript\u4e2d\u5176\u4e2d\u5185\u7f6e\u7c7b\u578b\uff1anull\u3001undefined\u3001string\u3001number\u3001boolean\u3001object\u3001symbol<br \/>\n2\u3001\u53d8\u91cf\u6ca1\u6709\u7c7b\u578b\uff0c\u4f46\u5b83\u4eec\u6301\u6709\u7684\u503c\u6709\u7c7b\u578b\uff0c\u7c7b\u578b\u5b9a\u4e49\u4e86\u503c\u7684\u884c\u4e3a\u7279\u5f81<br \/>\n3\u3001undefined:\u58f0\u660e\u8fc7\u672a\u8d4b\u503c\u53d8\u91cf\uff1bundeclared\uff1a\u6ca1\u58f0\u660e\u8fc7\n\t<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf4\u5230JavaScript\u91cc\u7684\u7c7b\u578b\u5f88\u5bb9\u6613\u5c31\u8ba9\u4eba\u60f3\u8d77 42\u548c&#8221;42&#8243;\uff0c\u5206\u522b\u662fstring\u578b&#8230;<\/p>\n","protected":false},"author":2,"featured_media":228,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[38],"tags":[],"_links":{"self":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/3217"}],"collection":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/comments?post=3217"}],"version-history":[{"count":1,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/3217\/revisions"}],"predecessor-version":[{"id":3219,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/3217\/revisions\/3219"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/media\/228"}],"wp:attachment":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/media?parent=3217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/categories?post=3217"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/tags?post=3217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}