{"id":447,"date":"2018-05-26T11:35:47","date_gmt":"2018-05-26T03:35:47","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=447"},"modified":"2018-05-26T11:35:47","modified_gmt":"2018-05-26T03:35:47","slug":"javascript%e5%bc%80%e5%8f%91%e8%a7%84%e8%8c%83%e8%bd%ac","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=447","title":{"rendered":"JavaScript\u5f00\u53d1\u89c4\u8303(\u8f6c)"},"content":{"rendered":"<p>\u4f5c\u4e3a\u4e00\u4e2a\u5c0f\u767d\u524d\u7aef\u770b\u4e86\u81ea\u5df1\u7684\u4ee3\u7801\u6709\u4e9b\u60ed\u6127\uff0c\u4e0a\u7f51\u627e\u5230\u4e86\u4e00\u4e2a\u5927\u795e\u5199\u7684\u89c4\u8303\uff0c\u4ee5\u540e\u79bb\u4e0d\u5f00\u8fd9\u4e2a\u89c4\u8303\u4e86\uff0c\u4e0b\u6b21\u5199\u7801\u65f6\u5019\u5c31\u628a\u8fd9\u4e2a\u89c4\u8303\u5f00\u4e2a\u7a97\u53e3\u52c9\u52b1\u81ea\u5df1\u3002<\/p>\n<p>\u539f\u6587\u5730\u5740\uff1ahttps:\/\/github.com\/kangkk\/web_develop_standard<\/p>\n<h3>javaScript\u4e66\u5199\u89c4\u8303\uff1a<\/h3>\n<hr \/>\n<blockquote>\n<ul>\n<li>\u547d\u540d\u89c4\u8303\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<pre><code>\t\u5e38\u91cf\u540d\r\n\t\t\u5168\u90e8\u5927\u5199\u5e76\u5355\u8bcd\u95f4\u7528\u4e0b\u5212\u7ebf\u5206\u9694\r\n\t\t\u5982\uff1aCSS_BTN_CLOSE\u3001TXT_LOADING\r\n<\/code><\/pre>\n<pre><code>\t\u5bf9\u8c61\u7684\u5c5e\u6027\u6216\u65b9\u6cd5\u540d\r\n\t\t\u5c0f\u9a7c\u5cf0\u5f0f\uff08little camel-case\uff09\r\n\t\t\u5982\uff1ainit\u3001bindEvent\u3001updatePosition\r\n\t\t\u793a\u4f8b\uff1aDialog.prototype = {\r\n\t\t\t\tinit: function () {},\r\n\t\t\t\tbindEvent: function () {},\r\n\t\t\t\tupdatePosition: function () {}\r\n\t\t\t\t \u2026\r\n\t\t\t};\r\n\t\u7c7b\u540d\uff08\u6784\u9020\u5668\uff09\r\n\t\t--&gt;\u5c0f\u9a7c\u5cf0\u5f0f\u4f46\u9996\u5b57\u6bcd\u5927\u5199\r\n\t\t--&gt;\u5982\uff1aCurrent\u3001DefaultConfig\r\n\t\u51fd\u6570\u540d\r\n\t\t--&gt;\u5c0f\u9a7c\u5cf0\u5f0f\r\n\t\t--&gt;\u5982\uff1acurrent()\u3001defaultConfig()\r\n\t\u53d8\u91cf\u540d\r\n\t\t--&gt;\u5c0f\u9a7c\u5cf0\u5f0f\r\n\t\t--&gt;\u5982\uff1acurrent\u3001defaultConfig\r\n\t\u79c1\u6709\u53d8\u91cf\u540d\r\n\t\t--&gt;\u5c0f\u9a7c\u5cf0\u5f0f\u4f46\u9700\u8981\u7528_\u5f00\u5934\r\n\t\t--&gt;\u5982\uff1a_current\u3001_defaultConfig\r\n\t\u53d8\u91cf\u540d\u7684\u524d\u7f00\r\n\t\t--&gt;\u7eed\r\n<\/code><\/pre>\n<blockquote>\n<ul>\n<li>\u4ee3\u7801\u683c\u5f0f\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<pre><code>\t\"()\"\u524d\u540e\u9700\u8981\u8ddf\u7a7a\u683c\r\n\t\"=\"\u524d\u540e\u9700\u8981\u8ddf\u7a7a\u683c\r\n\t\",\"\u540e\u9762\u9700\u8981\u8ddf\u7a7a\u683c\r\n\tJSON\u5bf9\u8c61\u9700\u683c\u5f0f\u5316\u5bf9\u8c61\u53c2\u6570\r\n\tif\u3001while\u3001for\u3001do\u8bed\u53e5\u7684\u6267\u884c\u4f53\u7528\"{}\"\u62ec\u8d77\u6765\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\"{}\"\u683c\u5f0f\u5982\u4e0b\u3002\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\tif (a==1) {\r\n\t\t\/\/\u4ee3\u7801\r\n\t};\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u907f\u514d\u989d\u5916\u7684\u9017\u53f7\u3002\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\tvar arr = [1,2,3,];\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>`for-in`\u5faa\u73af\u4f53\u4e2d\u5fc5\u987b\u7528`hasOwnProperty`\u65b9\u6cd5\u68c0\u67e5\u6210\u5458\u662f\u5426\u4e3a\u81ea\u8eab\u6210\u5458\uff0c\u907f\u514d\u6765\u81ea\u539f\u578b\u94fe\u4e0a\u7684\u6c61\u67d3\u3002\r\n<\/code><\/pre>\n<ul>\n<li>\u957f\u8bed\u53e5\u53ef\u8003\u8651\u65ad\u884c\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<pre><code>\tTEMPL_SONGLIST.replace('{TABLE}', da['results'])\r\n\t\t.replace('{PREV_NUM}', prev)\r\n\t\t.replace('{NEXT_NUM}', next)\r\n\t\t.replace('{CURRENT_NUM}', current)\r\n\t\t.replace('{TOTAL_NUM}', da.page_total);\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u4e3a\u4e86\u907f\u514d\u548c`JSLint`\u7684\u68c0\u9a8c\u673a\u5236\u51b2\u7a81\uff0c\u201c.\u201d\u6216\u201c+\u201d\u8fd9\u7c7b\u64cd\u4f5c\u7b26\u653e\u5728\u884c\u5c3e\u3002\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\tTEMPL_SONGLIST.replace('{TABLE}', da['results']).\r\n\t\treplace('{PREV_NUM}', prev).\r\n\t\treplace('{NEXT_NUM}', next).\r\n\t\treplace('{CURRENT_NUM}', current).\r\n\t\treplace('{TOTAL_NUM}', da.page_total);\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u5982\u679c\u6a21\u5757\u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528\u5176\u5b83\u5168\u5c40\u53d8\u91cf\u60f3\u8df3\u8fc7JSLint\u7684\u68c0\u67e5\uff0c\u53ef\u4ee5\u5728\u8be5\u6587\u4ef6\u4e2d\u52a0\u5165`\/*global*\/`\u58f0\u660e\u3002\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\t\/*global alert: true, console: true, top: true, setTimeout: true *\/\r\n<\/code><\/pre>\n<blockquote>\n<ul>\n<li>\u4f7f\u7528\u4e25\u683c\u7684\u6761\u4ef6\u5224\u65ad\u7b26\u3002\u7528===\u4ee3\u66ff==\uff0c\u7528!==\u4ee3\u66ff!=\uff0c\u907f\u514d\u6389\u5165==\u9020\u6210\u7684\u9677\u9631 \u5728\u6761\u4ef6\u5224\u65ad\u65f6\uff0c\u8fd9\u6837\u7684\u4e00\u4e9b\u503c\u8868\u793afalse\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<pre><code>\tnull\r\n\tundefined\u4e0enull\u76f8\u7b49\r\n\t\u5b57\u7b26\u4e32''\r\n\t\u6570\u5b570\r\n\tNaN\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u5728==\u65f6\uff0c\u5219\u4f1a\u6709\u4e00\u4e9b\u8ba9\u4eba\u96be\u4ee5\u7406\u89e3\u7684\u9677\u9631\u3002\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\t(function () {\r\n\t\tvar undefined;\r\n\t\tundefined == null; \/\/ true\r\n\t\t1 == true; \/\/true\r\n\t\t2 == true; \/\/ false\r\n\t\t0 == false; \/\/ true\r\n\t\t0 == ''; \/\/ true\r\n\t\tNaN == NaN;\/\/ false\r\n\t\t[] == false; \/\/ true\r\n\t\t[] == ![]; \/\/ true\r\n\t})();\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u5bf9\u4e8e\u4e0d\u540c\u7c7b\u578b\u7684 == \u5224\u65ad\uff0c\u6709\u8fd9\u6837\u4e00\u4e9b\u89c4\u5219\uff0c\u987a\u5e8f\u81ea\u4e0a\u800c\u4e0b\uff1a\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\tundefined\u4e0enull\u76f8\u7b49\r\n\t\u4e00\u4e2a\u662fnumber\u4e00\u4e2a\u662fstring\u65f6\uff0c\u4f1a\u5c1d\u8bd5\u5c06string\u8f6c\u6362\u4e3anumber\r\n\t\u5c1d\u8bd5\u5c06boolean\u8f6c\u6362\u4e3anumber\r\n\t0\u62161\r\n\t\u5c1d\u8bd5\u5c06Object\u8f6c\u6362\u6210number\u6216string\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u800c\u8fd9\u4e9b\u53d6\u51b3\u4e8e\u53e6\u5916\u4e00\u4e2a\u5bf9\u6bd4\u91cf\uff0c\u5373\u503c\u7684\u7c7b\u578b\uff0c\u6240\u4ee5\u5bf9\u4e8e0\u3001\u7a7a\u5b57\u7b26\u4e32\u7684\u5224\u65ad\uff0c\u5efa\u8bae\u4f7f\u7528`===`\r\n\u3002`===`\u4f1a\u5148\u5224\u65ad\u4e24\u8fb9\u7684\u503c\u7c7b\u578b\uff0c\u7c7b\u578b\u4e0d\u5339\u914d\u65f6\u4e3a`false`\u3002\r\n<\/code><\/pre>\n<ul>\n<li>\u4e0b\u9762\u7c7b\u578b\u7684\u5bf9\u8c61\u4e0d\u5efa\u8bae\u7528new\u6784\u9020\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<pre><code>\tnew Number\r\n\tnew String\r\n\tnew Boolean\r\n\tnew Object \/\/\u7528{}\u4ee3\u66ff\r\n\tnew Array \/\/\u7528[]\u4ee3\u66ff\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u5f15\u7528\u5bf9\u8c61\u6210\u5458\u7528`obj.prop`\u4ee3\u66ff`obj[\"prop\"]`\uff0c\u9664\u975e\u5c5e\u6027\u540d\u662f\u53d8\u91cf\u3002\r\n<\/code><\/pre>\n<ul>\n<li>\u4ecenumber\u5230string\u7684\u8f6c\u6362\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<pre><code>\t\/** \u63a8\u8350\u5199\u6cd5*\/\r\n\tvar a = 1;\r\n\ttypeof(a); \/\/\"number\"\r\n\tconsole.log(a); \/\/1\r\n\tvar aa=a+'';\r\n\ttypeof(aa); \/\/\"string\"\r\n\tconsole.log(aa); \/\/'1'\r\n\t\/** \u4e0d\u63a8\u8350\u5199\u6cd5*\/\r\n\tnew String(a)\u6216a.toString()\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u4ecestring\u5230number\u7684\u8f6c\u6362\uff0c\u4f7f\u7528parseInt\uff0c\u5fc5\u987b\u663e\u5f0f\u6307\u5b9a\u7b2c\u4e8c\u4e2a\u53c2\u6570\u7684\u8fdb\u5236\u3002\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\t\/** \u63a8\u8350\u5199\u6cd5*\/\r\n\tvar a = '1';\r\n\tvar aa = parseInt(a,10);\r\n\ttypeof(a); \/\/\"string\"\r\n\tconsole.log(a); \/\/'1'\r\n\ttypeof(aa); \/\/\"number\"\r\n\tconsole.log(aa); \/\/1\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u4ecefloat\u5230integer\u7684\u8f6c\u6362\u3002\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\t\/** \u63a8\u8350\u5199\u6cd5*\/\r\n\tMath.floor\/Math.round\/Math.ceil\r\n\t\/** \u4e0d\u63a8\u8350\u5199\u6cd5*\/\r\n\tparseInt\r\n<\/code><\/pre>\n<blockquote>\n<pre><code>\u5b57\u7b26\u4e32\u62fc\u63a5\u5e94\u4f7f\u7528\u6570\u7ec4\u4fdd\u5b58\u5b57\u7b26\u4e32\u7247\u6bb5\uff0c\u4f7f\u7528\u65f6\u8c03\u7528join\u65b9\u6cd5\u3002\u907f\u514d\u4f7f\u7528+\u6216+=\u7684\u65b9\u5f0f\u62fc\u63a5\u8f83\u957f\u7684\u5b57\u7b26\u4e32\uff0c\u6bcf\u4e2a\u5b57\u7b26\u4e32\u90fd\u4f1a\u4f7f\u7528\u4e00\u4e2a\u5c0f\u7684\u5185\u5b58\u7247\u6bb5\uff0c\u8fc7\u591a\u7684\u5185\u5b58\u7247\u6bb5\u4f1a\u5f71\u54cd\u6027\u80fd\u3002\r\n<\/code><\/pre>\n<\/blockquote>\n<pre><code>\t\/**\u63a8\u8350\u7684\u62fc\u63a5\u65b9\u5f0farray\u7684push\u3001join*\/\r\n\tvar str=[],\r\n\t\tlist=['\u6d4b\u8bd5A','\u6d4b\u8bd5B'];\r\n\tfor (var i=0 , len=list.length; i &lt; len; i++) {\r\n\t\tstr.push( '&lt;div&gt;'+ list[i] + '&lt;\/div&gt;');\r\n\t};\r\n\tconsole.log(str.join('')); \/\/&lt;div&gt;\u6d4b\u8bd5A&lt;\/div&gt;&lt;div&gt;\u6d4b\u8bd5B&lt;\/div&gt;\r\n\t\/** \u4e0d\u63a8\u8350\u7684\u62fc\u63a5\u65b9\u5f0f+=*\/\r\n\tvar str = '',\r\n\t\tlist=['\u6d4b\u8bd5A','\u6d4b\u8bd5B'];\r\n\tfor (var i = 0, len = list.length; i&lt; len; i++) {\r\n\t\tstr+='&lt;div&gt;' + list[i] + '&lt;\/div&gt;';\r\n\t};\r\n\tconsole.log(str); \/\/&lt;div&gt;\u6d4b\u8bd5A&lt;\/div&gt;&lt;div&gt;\u6d4b\u8bd5B&lt;\/div&gt;\r\n<\/code><\/pre>\n<blockquote>\n<ul>\n<li>\u5c3d\u91cf\u907f\u514d\u4f7f\u7528\u5b58\u5728\u517c\u5bb9\u6027\u53ca\u6d88\u8017\u8d44\u6e90\u7684\u65b9\u6cd5\u6216\u5c5e\u6027\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<pre><code>\t\u4e0d\u8981\u4f7f\u7528with\uff0cvoid\uff0cevil\uff0ceval_r\uff0cinnerText\r\n<\/code><\/pre>\n<blockquote>\n<ul>\n<li>\u6ce8\u91cd<code>HTML<\/code>\u5206\u79bb, \u51cf\u5c0f<code>reflow<\/code>, \u6ce8\u91cd\u6027\u80fd\u3002<\/li>\n<\/ul>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u4e00\u4e2a\u5c0f\u767d\u524d\u7aef\u770b\u4e86\u81ea\u5df1\u7684\u4ee3\u7801\u6709\u4e9b\u60ed\u6127\uff0c\u4e0a\u7f51\u627e\u5230\u4e86\u4e00\u4e2a\u5927\u795e\u5199\u7684\u89c4\u8303\uff0c\u4ee5\u540e\u79bb\u4e0d\u5f00\u8fd9\u4e2a\u89c4\u8303\u4e86\uff0c\u4e0b\u6b21\u5199\u7801\u65f6\u5019\u5c31\u628a\u8fd9\u4e2a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":180,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[19],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/447"}],"collection":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=447"}],"version-history":[{"count":1,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/447\/revisions"}],"predecessor-version":[{"id":448,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/447\/revisions\/448"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/media\/180"}],"wp:attachment":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=447"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}