{"id":1652,"date":"2024-11-10T14:58:19","date_gmt":"2024-11-10T06:58:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1652\/"},"modified":"2024-11-10T14:58:19","modified_gmt":"2024-11-10T06:58:19","slug":"js%e5%af%b9%e8%b1%a1%e5%b1%9e%e6%80%a7%e8%b0%83%e7%94%a8%e6%96%b9%e6%b3%95%e6%8a%a5invalid-left-hand-side-expression%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1652\/","title":{"rendered":"JS\u5bf9\u8c61\u5c5e\u6027\u8c03\u7528\u65b9\u6cd5\u62a5Invalid Left-Hand Side Expression\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173052655532279.jpg\" class=\"aligncenter\" title=\"JS\u5bf9\u8c61\u5c5e\u6027\u8c03\u7528\u65b9\u6cd5\u62a5Invalid Left-Hand Side Expression\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"JS\u5bf9\u8c61\u5c5e\u6027\u8c03\u7528\u65b9\u6cd5\u62a5Invalid Left-Hand Side Expression\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>js\u5bf9\u8c61\u5c5e\u6027\u8c03\u7528\u65b9\u6cd5\u62a5invalid left-hand side expression<\/strong><\/p>\n<p>\u5728js\u4ee3\u7801\u4e2d\u9047\u5230\u4e00\u4e2a\u95ee\u9898\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>var test = {\n  a: function() {\n    return 1;\n  },\n  fn: {\n    fn1: test.a\n\n  },\n  exec: function() {\n    return fn.fn1();\n  },\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5f53\u6211\u8c03\u7528test.exec()\u65b9\u6cd5\u65f6\uff0c\u5374\u51fa\u73b0\u4e86invalid left-hand side expression\u7684\u9519\u8bef\u3002\u8fd9\u662f\u600e\u4e48\u56de\u4e8b\uff1f<\/p>\n<p><strong>\u89e3\u6790\uff1a<\/strong><\/p>\n<p>\u9519\u8bef\u7684\u539f\u56e0\u662ffn\u5bf9\u8c61\u6ca1\u6709\u88ab\u89e3\u6790\u3002\u5728\u4ee3\u7801\u4e2d\uff0cfn\u88ab\u58f0\u660e\u4e3atest.fn\uff0c\u4f46\u662ftest\u5bf9\u8c61\u8fd8\u6ca1\u6709\u89e3\u6790\u5b8c\u6210\uff0c\u6240\u4ee5\u65e0\u6cd5\u8bbf\u95ee\u5176\u5c5e\u6027\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u65b9\u6cd51\uff1a<\/strong>\u5c06fn\u5bf9\u8c61\u89e3\u6790\u4e3atest\u5bf9\u8c61\u7684\u5c5e\u6027\u540e\uff0c\u518d\u7ee7\u7eed\u5f15\u7528\u5b83\u7684\u65b9\u6cd5\uff1a<\/p>\n<pre>var test = {\n  a: function() {\n    return 1;\n  }\n};\n\ntest.fn = {\n  fn1: test.a\n};\n\ntest.exec = function() {\n  return test.fn.fn1();\n};<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u65b9\u6cd52\uff1a<\/strong>\u76f4\u63a5\u5c06test.a\u65b9\u6cd5\u8d4b\u503c\u7ed9fn1\u5c5e\u6027\uff1a<\/p>\n<pre>var test = {\n  a: function() {\n    return 1;\n  },\n  fn: {\n    fn1: this.a\n  },\n  exec: function() {\n    return this.fn.fn1();\n  }\n};<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e24\u79cd\u65b9\u6cd5\u4e2d\u7684\u4e00\u79cd\uff0c\u5c31\u53ef\u4ee5\u89e3\u51b3invalid left-hand side expression\u9519\u8bef\uff0c\u5e76\u6b63\u5e38\u8c03\u7528test.exec()\u65b9\u6cd5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fJS\u5bf9\u8c61\u5c5e\u6027\u8c03\u7528\u65b9\u6cd5\u62a5Invalid Left-Hand Side Expression\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>js\u5bf9\u8c61\u5c5e\u6027\u8c03\u7528\u65b9\u6cd5\u62a5invalid left-hand side expression \u5728js\u4ee3\u7801\u4e2d\u9047\u5230\u4e00\u4e2a\u95ee\u9898\uff0c\u5982\u4e0b\u6240\u793a\uff1a var test = { a: function() { return 1; }, fn: { fn1: test.a }, exec: function() { return fn.fn1(); }, } \u767b\u5f55\u540e\u590d\u5236 \u5f53\u6211\u8c03\u7528test.exec()\u65b9\u6cd5\u65f6\uff0c\u5374\u51fa\u73b0\u4e86invalid left-hand side expression\u7684\u9519\u8bef\u3002\u8fd9\u662f\u600e\u4e48\u56de\u4e8b\uff1f \u89e3\u6790\uff1a \u9519\u8bef\u7684\u539f\u56e0\u662ffn\u5bf9\u8c61\u6ca1\u6709\u88ab\u89e3\u6790\u3002\u5728\u4ee3\u7801\u4e2d\uff0cfn\u88ab\u58f0\u660e\u4e3atest.fn\uff0c\u4f46\u662ftest\u5bf9\u8c61\u8fd8\u6ca1\u6709\u89e3\u6790\u5b8c\u6210\uff0c\u6240\u4ee5\u65e0\u6cd5\u8bbf\u95ee\u5176\u5c5e\u6027\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a \u65b9\u6cd51\uff1a\u5c06fn\u5bf9\u8c61\u89e3\u6790\u4e3atest\u5bf9\u8c61\u7684\u5c5e\u6027\u540e\uff0c\u518d\u7ee7\u7eed\u5f15\u7528\u5b83\u7684\u65b9\u6cd5\uff1a var test = { a: function() { return 1; } }; test.fn = { fn1: test.a }; test.exec [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1652","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=1652"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1652\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}