\/\/ 128<\/em><\/code><\/pre>\n\n\n\n\u4e0a\u9762\u4ee3\u7801\u7684\u95ee\u9898\u662f\u53d8\u91cf i \u662f\u5168\u5c40\u58f0\u660e\u7684\uff0c\u5982\u679c\u6211\u4eec\u60f3\u91cd\u65b0\u542f\u52a8\u5e8f\u5217\uff0c\u6211\u4eec\u5fc5\u987b\u4ee5\u6b63\u786e\u7684\u65b9\u5f0f\u64cd\u4f5c\u8fd9\u4e2a\u53d8\u91cf\uff0c\u6cc4\u9732 getter \u7684\u5b9e\u73b0\u7ec6\u8282\u3002<\/p>\n\n\n\n
\u4e3a\u4e86\u4f7f\u4e0a\u9762\u7684\u4ee3\u7801\u53ef\u91cd\u7528\u5e76\u4e14\u6ca1\u6709\u5168\u5c40\u53d8\u91cf\uff0c\u9700\u8981\u505a\u7684\u662f\u5c06 getter \u5305\u88c5\u5728\u53e6\u4e00\u4e2a\u51fd\u6570\u4e2d\u3002\u800c\u4e14\u8fd9\u4e2a\u5305\u88c5\u51fd\u6570\u4e5f\u662f\u4e00\u4e2agetter\u3002<\/p>\n\n\n\n
getter-getters\u4f1a\u7ee7\u627fgetter\u7684\u6240\u4ee5\u4f18\u70b9\u3002\u6bd4\u5982\uff1a\u4f8b\u5982\uff1a\uff081\uff09\u5b9e\u73b0\u7684\u7075\u6d3b\u6027\uff0c\uff082\uff09\u526f\u4f5c\u7528\u7684\u94a9\u5b50\uff0c\uff083\uff09\u60f0\u6027\u3002\u8fd9\u6b21\u7684\u60f0\u6027\u4f53\u73b0\u5728\u521d\u59cb\u5316\u6b65\u9aa4\u4e2d\u3002\u5916\u90e8\u51fd\u6570\u53ef\u4ee5\u5ef6\u8fdf\u53d8\u91cf\u521d\u59cb\u5316\uff0c\u800c\u5185\u90e8\u51fd\u6570\u53ef\u4ee5\u5ef6\u8fdf\u904d\u5386\u503c\u3002<\/p>\n\n\n\n
function getGetNext() {\n let i = 2;\n return function getNext() {\n const next = i;\n i = i * 2;\n return next;\n }\n}\n\nlet getNext = getGetNext();\nconsole.log(getNext()); \/\/ 2\nconsole.log(getNext()); \/\/ 4\nconsole.log(getNext()); \/\/ 8\ngetNext = getGetNext(); \/\/ \ud83d\udd37 restart!\nconsole.log(getNext()); \/\/ 2\nconsole.log(getNext()); \/\/ 4\nconsole.log(getNext()); \/\/ 8\nconsole.log(getNext()); \/\/ 16\nconsole.log(getNext()); \/\/ 32<\/code><\/pre>\n\n\n\nIterables<\/h4>\n\n\n\n
() => (() => ({done, value}))<\/code><\/p>\n\n\n\n\u53ef\u8fed\u4ee3\u51fd\u6570\u662f\u7279\u6b8a\u5316\u7684getter-getter\uff0c\u8fd4\u56de\u4e00\u4e2a\u5bf9\u8c61\u5f62\u5f0f\u5305\u542bvalue\u548cdone\u7684x\u503c\u3002<\/p>\n\n\n\n