{"id":1909,"date":"2023-03-25T14:26:38","date_gmt":"2023-03-25T06:26:38","guid":{"rendered":""},"modified":"2023-03-25T14:26:38","modified_gmt":"2023-03-25T06:26:38","slug":"ES6 \u8fd0\u7b97\u7b26","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/1909.html","title":{"rendered":"ES6 \u8fd0\u7b97\u7b26"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

ES6 \u8fd0\u7b97\u7b26<\/h1>\n<\/p><\/div>\n

ES6 \u64cd\u4f5c\u7b26<\/h2>\n
\n \u64cd\u4f5c\u7b26\u53ef\u4ee5\u5b9a\u4e49\u4e3a\u4e00\u4e2a\u7b26\u53f7\uff0c\u544a\u8bc9\u7cfb\u7edf\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\u3002\u5728 JavaScript \u4e2d\uff0c\u6709\u4e00\u7ec4\u4e30\u5bcc\u7684\u8fd0\u7b97\u7b26\uff0c\u901a\u8fc7\u4f7f\u7528\u7279\u5b9a\u7684\u8fd0\u7b97\u7b26\uff0c\u60a8\u53ef\u4ee5\u6267\u884c\u4efb\u4f55\u7279\u5b9a\u4efb\u52a1\u3002\n <\/div>\n
\n \u5728\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u8fd0\u7b97\u7b26\u6765\u8bc4\u4f30\u4e0d\u540c\u7684\u64cd\u4f5c\u6570\u3002\n <\/div>\n
\n \u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u8fd4\u56de\u503c\u7684\u8bed\u53e5\u3002\u8868\u8fbe\u5f0f\u5305\u62ec:\n <\/div>\n

Operators: \u8d1f\u8d23\u5bf9\u64cd\u4f5c\u6570\u8fdb\u884c\u4e00\u4e9b\u64cd\u4f5c<\/span>
\n \u64cd\u4f5c\u6570: \u4ee3\u8868\u6570\u636e\u3002<\/span> <\/p>\n

\n \u4f8b\u5982: \u5047\u8bbe\u4e00\u4e2a\u8868\u8fbe\u5f0f\u50cf x*y\u3002\u5728\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u4e2d\uff0c x \u548cy \u662f\u64cd\u4f5c\u6570\uff0c\u661f\u53f7(*)\u662f\u4e58\u6cd5\u8fd0\u7b97\u7b26\u3002\n <\/div>\n

\u8fd0\u7b97\u7b26\u7684\u7c7b\u578b<\/h2>\n
\n JavaScript \u4e2d\u7684\u8fd0\u7b97\u7b26\u53ef\u5206\u4e3a:\n <\/div>\n

\u7b97\u672f\u8fd0\u7b97\u7b26<\/span>
\n \u5173\u7cfb\u8fd0\u7b97\u7b26<\/span>
\n \u903b\u8f91\u8fd0\u7b97\u7b26<\/span>
\n \u8d4b\u503c\u8fd0\u7b97\u7b26<\/span>
\n \u6309\u4f4d\u8fd0\u7b97\u7b26<\/span>
\n \u7c7b\u578b\u8fd0\u7b97\u7b26<\/span>
\n \u6742\u9879\u64cd\u4f5c\u5458<\/span> <\/p>\n

\n \u8ba9\u6211\u4eec\u5c1d\u8bd5\u8be6\u7ec6\u9610\u8ff0\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u3002\n <\/div>\n

\u7b97\u672f\u8fd0\u7b97\u7b26<\/h3>\n
\n \u7b97\u672f\u8fd0\u7b97\u7b26\u662f\u53ef\u7528\u7684\u57fa\u672c\u6570\u5b66\u8fd0\u7b97\u7b26JavaScript ES6\u3001\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u8d1f\u8d23\u6267\u884c JavaScript \u4e2d\u7684\u6240\u6709\u6570\u5b66\u8fd0\u7b97\uff0c\u4f8b\u5982\u52a0\u6cd5\u3001\u51cf\u6cd5\u7b49\u3002\n <\/div>\n\n\n\n\n\n\n\n\n\n\n
\u8fd0\u8425\u5546<\/td>\n\u51fd\u6570<\/td>\n<\/tr>\n
+(\u6dfb\u52a0)<\/td>\n\u8fd4\u56de\u64cd\u4f5c\u6570\u7684\u603b\u548c<\/td>\n<\/tr>\n
-(\u51cf\u6cd5)<\/td>\n\u8fd4\u56de\u64cd\u4f5c\u6570\u4e4b\u95f4\u7684\u5dee\u503c<\/td>\n<\/tr>\n
*(\u4e58\u6cd5)<\/td>\n\u5b83\u8fd4\u56de\u64cd\u4f5c\u6570\u503c\u7684\u4e58\u79ef\u3002<\/td>\n<\/tr>\n
\/(\u90e8\u95e8)<\/td>\n\u7528\u4e8e\u9664\u6cd5\uff0c\u8fd4\u56de\u5546\u3002<\/td>\n<\/tr>\n
%(\u6a21\u6570)<\/td>\n\u5b83\u8fd8\u6267\u884c\u9664\u6cd5\u5e76\u8fd4\u56de\u4f59\u6570\u3002<\/td>\n<\/tr>\n
++(\u589e\u91cf)<\/td>\n\u5c06\u53d8\u91cf\u7684\u503c\u52a0\u4e00\u3002<\/td>\n<\/tr>\n
-(\u9012\u51cf)<\/td>\n\u5c06\u53d8\u91cf\u7684\u503c\u51cf\u4e00\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u4f8b\u5982\n <\/div>\n
\n \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u4e0a\u9762\u5217\u51fa\u7684\u6240\u6709\u7b97\u672f\u8fd0\u7b97\u7b26:\n <\/div>\n
\n
var <\/span>x = 30; \nvar <\/span>y = 20 ;\nconsole.log<\/span>(\"Addition: \"<\/span> + (x + y) );\nconsole.log<\/span>(\"Subtraction: \"<\/span> + (x-y) );\nconsole.log<\/span>(\"Multiplication: \"<\/span> + (x * y) );\nconsole.log<\/span>(\"The Division will give you the quotient: \"<\/span> + (x \/ y) );\nconsole.log<\/span>(\"Modulus will give you the Remainder: \"<\/span> + (x % y) );\n\/\/ pre-increment <\/span>\nconsole.log<\/span>(\"Value of x after pre-increment: \"<\/span>  + (++x) );\n\/\/ post-increment <\/span>\nconsole.log<\/span>(\"Value of x after post-increment: \"<\/span> + (x++) );\n\/\/ pre-decrement <\/span>\nconsole.log<\/span>(\"Value of y after pre-decrement: \"<\/span>  + (--y) );\n\/\/ post-decrement <\/span>\nconsole.log<\/span>(\"Value of y after post-decrement: \"<\/span> + (y--) );<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n \u5f53\u4f60\u5728\u7ec8\u7aef\u4e2d\u6267\u884c\u4e0a\u8ff0\u4ee3\u7801\u65f6\uff0c\u4f60\u4f1a\u5f97\u5230\u5982\u4e0b\u8f93\u51fa:\n <\/div>\n
\n
Addition : 50\nSubtraction: 10\nMultiplication: 600\nThe division will give you the quotient: 1.5\nModulus will give you the Remainder: 10\nValue of x after pre-increment: 31\nValue of x after post-increment: 31\nValue of y after pre-decrement: 19\nValue of y after post-decrement: 19<\/pre>\n

<\/code>\n <\/div>\n

\u5173\u7cfb\u8fd0\u7b97\u7b26<\/h3>\n
\n \u5173\u7cfb\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u503c\u5e76\u6839\u636e\u8868\u8fbe\u5f0f\u8fd4\u56de\u771f\u6216\u5047\u3002\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u6709\u65f6\u79f0\u4e3a\u6bd4\u8f83\u8fd0\u7b97\u7b26\u3002\n <\/div>\n\n\n\n\n\n\n\n\n\n
\u64cd\u4f5c\u5458<\/td>\n\u529f\u80fd<\/td>\n<\/tr>\n
>(\u5927\u4e8e)<\/td>\n\u5982\u679c\u5de6\u64cd\u4f5c\u6570\u5927\u4e8e\u53f3\u64cd\u4f5c\u6570\u5219\u8fd4\u200b\u200b\u56de\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002<\/td>\n<\/tr>\n
<(\u5c0f\u4e8e)<\/td>\n\u5982\u679c\u5de6\u64cd\u4f5c\u6570\u5c0f\u4e8e\u53f3\u64cd\u4f5c\u6570\u5219\u8fd4\u200b\u200b\u56de\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002 <\/td>\n<\/tr>\n
>=(\u5927\u4e8e\u6216\u7b49\u4e8e)<\/td>\n\u5982\u679c\u5de6\u64cd\u4f5c\u6570\u5927\u4e8e\u6216\u7b49\u4e8e\u53f3\u64cd\u4f5c\u6570\u5219\u8fd4\u200b\u200b\u56de\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002<\/td>\n<\/tr>\n
<=(\u5c0f\u4e8e\u6216\u7b49\u4e8e)<\/td>\n\u5982\u679c\u5de6\u64cd\u4f5c\u6570\u5c0f\u4e8e\u6216\u7b49\u4e8e\u53f3\u64cd\u4f5c\u6570\u5219\u8fd4\u200b\u200b\u56de\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002 <\/td>\n<\/tr>\n
==(\u5e73\u7b49)<\/td>\n\u5982\u679c\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u503c\u76f8\u540c\u5219\u8fd4\u56de\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002<\/td>\n<\/tr>\n
!=(\u4e0d\u7b49\u4e8e)<\/td>\n\u5982\u679c\u64cd\u4f5c\u6570\u7684\u503c\u4e0d\u540c\u5219\u8fd4\u56de\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u4f8b\u5982:\n <\/div>\n
\n \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u4e0a\u9762\u5217\u51fa\u7684\u6240\u6709\u5173\u7cfb\u8fd0\u7b97\u7b26\n <\/div>\n
\n
var <\/span>x = 20; \nvar <\/span>y = 15; \nconsole.log<\/span>(\"Value of x: \"<\/span> + x); \nconsole.log<\/span>(\"Value of y: \"<\/span> + y); \nvar <\/span>result = x > y; \nconsole.log<\/span>(\"x is greater than y: \"<\/span> + result); \nresult = x < y; \nconsole.log<\/span>(\"x is smaller than y: \"<\/span> + result); \nresult = x >= y; \nconsole.log<\/span>(\"x is greater than or equal to  y: \"<\/span> + result); \nresult = x <= y; \nconsole.log<\/span>(\"x is smaller than or equal to y: \"<\/span> + result); \nresult = x == y; \nconsole.log<\/span>(\"x is equal to y: \"<\/span> + result); \nresult = x != y; \nconsole.log<\/span>(\"x not equal to  y: \"<\/span> + result);<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n \u5f53\u4f60\u5728\u7ec8\u7aef\u4e2d\u6267\u884c\u8fd9\u6bb5\u4ee3\u7801\u65f6\uff0c\u4f60\u4f1a\u5f97\u5230\u5982\u4e0b\u8f93\u51fa:\n <\/div>\n
\n
Value of x: 20\nValue of y: 15\nx is greater than y: true<\/span><\/span>\nx is smaller than y: false<\/span>\nx is greater than or equal to  y: true<\/span><\/span>\nx is smaller than or equal to y: false<\/span>\nx is equal to y: false<\/span>\nx not equal to  y: true<\/span><\/span><\/pre>\n

<\/code>\n <\/div>\n

\u903b\u8f91\u8fd0\u7b97\u7b26<\/h3>\n
\n \u903b\u8f91\u8fd0\u7b97\u7b26\u901a\u5e38\u7528\u4e8e\u7ec4\u5408\u4e24\u4e2a\u6216\u591a\u4e2a\u5173\u7cfb\u8bed\u53e5\u3002\u5b83\u4eec\u8fd8\u8fd4\u56de\u5e03\u5c14\u503c\u3002\n <\/div>\n\n\n\n\n\n\n
\u8fd0\u8425\u5546<\/td>\n\u8bf4\u660e<\/td>\n<\/tr>\n
&&(\u903b\u8f91\u4e0e)<\/td>\n\u5982\u679c\u6240\u6709\u4e0e && \u7ec4\u5408\u7684\u5173\u7cfb\u8bed\u53e5\u90fd\u4e3a\u771f\uff0c\u5219\u6b64\u8fd0\u7b97\u7b26\u8fd4\u56de\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002<\/td>\n<\/tr>\n
||(\u903b\u8f91\u6216)<\/td>\n\u5982\u679c\u81f3\u5c11\u6709\u4e00\u4e2a\u4e0e || \u7ec4\u5408\u7684\u5173\u7cfb\u8bed\u53e5\uff0c\u5219\u6b64\u8fd0\u7b97\u7b26\u8fd4\u56de true\u4e3a\u771f\uff0c\u5426\u5219\u8fd4\u56de\u5047\u3002<\/td>\n<\/tr>\n
!(\u903b\u8f91\u975e)<\/td>\n\u5b83\u8fd4\u56de\u8bed\u53e5\u7ed3\u679c\u7684\u5012\u6570\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u4f8b\u5982:\n <\/div>\n
\n \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u4e0a\u9762\u5217\u51fa\u7684\u6240\u6709\u903b\u8f91\u8fd0\u7b97\u7b26\u3002\n <\/div>\n
\n
var <\/span>x = 30; \nvar <\/span>y = 80; \nconsole.log<\/span>(\"Value of x = \"<\/span> + x );\nconsole.log<\/span>(\"Value of y = \"<\/span> + y );\nvar <\/span>result = ((x < 40) && (y <= 90)); \nconsole.log<\/span>(\"(x < 40) && (y <= 90): \"<\/span>, result); \nvar <\/span>result = ((x == 50) ||<\/span> (y > 80)); \nconsole.log<\/span>(\"(x == 50) |<\/span>| (y > 80): \"<\/span>, result); \nvar <\/span>result = !((x > 20) && (y >= 80)); \nconsole.log<\/span>(\"!((x > 20) && (y >= 80)): \"<\/span>, result);<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n
Value of x = 30\nValue of y = 80\n(x < 40) && (y <= 90):  true<\/span><\/span>\n(x == 50) ||<\/span> (y > 80):  false<\/span>\n!((x > 20) && (y >= 80)):  false<\/span><\/pre>\n

<\/code>\n <\/div>\n

\u8d4b\u503c\u8fd0\u7b97\u7b26<\/h3>\n
\n \u8d4b\u503c\u8fd0\u7b97\u7b26\u7528\u4e8e\u4e3a\u53d8\u91cf\u8d4b\u503c\u3002\u8d4b\u503c\u8fd0\u7b97\u7b26\u5de6\u8fb9\u7684\u64cd\u4f5c\u6570\u662f\u4e00\u4e2a\u53d8\u91cf\uff0c\u8d4b\u503c\u8fd0\u7b97\u7b26\u53f3\u8fb9\u7684\u64cd\u4f5c\u6570\u662f\u4e00\u4e2a\u503c\u3002\n <\/div>\n
\n \u53f3\u8fb9\u7684\u503c\u5fc5\u987b\u662f\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578b\u5de6\u4fa7\u53d8\u91cf\uff1b\u5426\u5219\u7f16\u8bd1\u5668\u4f1a\u62a5\u9519\u3002\n <\/div>\n\n\n\n\n\n\n\n\n
\u8fd0\u8425\u5546<\/td>\n\u51fd\u6570<\/td>\n<\/tr>\n
=(\u7b80\u5355\u8d4b\u503c)<\/td>\n\u5b83\u53ea\u662f\u5c06\u53f3\u64cd\u4f5c\u6570\u7684\u503c\u8d4b\u7ed9\u5de6\u64cd\u4f5c\u6570<\/td>\n<\/tr>\n
+=(\u6dfb\u52a0\u548c\u5206\u914d)<\/td>\n\u6b64\u8fd0\u7b97\u7b26\u5c06\u53f3\u64cd\u4f5c\u6570\u7684\u503c\u4e0e\u5de6\u64cd\u4f5c\u6570\u7684\u503c\u76f8\u52a0\uff0c\u5e76\u5c06\u7ed3\u679c\u8d4b\u7ed9\u5de6\u64cd\u4f5c\u6570\u3002<\/td>\n<\/tr>\n
-=(\u51cf\u6cd5\u548c\u8d4b\u503c)<\/td>\n\u6b64\u8fd0\u7b97\u7b26\u4ece\u5de6\u64cd\u4f5c\u6570\u7684\u503c\u4e2d\u51cf\u53bb\u53f3\u64cd\u4f5c\u6570\u7684\u503c\uff0c\u5e76\u5c06\u7ed3\u679c\u8d4b\u7ed9\u5de6\u64cd\u4f5c\u6570\u3002<\/td>\n<\/tr>\n
*=(\u4e58\u6cd5\u548c\u8d4b\u503c)<\/td>\n\u6b64\u8fd0\u7b97\u7b26\u5c06\u53f3\u64cd\u4f5c\u6570\u7684\u503c\u4e58\u4ee5\u5de6\u64cd\u4f5c\u6570\u7684\u503c\uff0c\u5e76\u5c06\u7ed3\u679c\u8d4b\u7ed9\u5de6\u64cd\u4f5c\u6570\u3002<\/td>\n<\/tr>\n
\/=(\u5206\u800c\u6cbb\u4e4b)<\/td>\n\u6b64\u8fd0\u7b97\u7b26\u5c06\u53f3\u64cd\u4f5c\u6570\u7684\u503c\u9664\u4ee5\u5de6\u64cd\u4f5c\u6570\u7684\u503c\uff0c\u5e76\u5c06\u7ed3\u679c\u8d4b\u7ed9\u5de6\u64cd\u4f5c\u6570\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u4f8b\u5982:\n <\/div>\n
\n \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u4e0a\u9762\u5217\u51fa\u7684\u6240\u6709\u903b\u8f91\u8fd0\u7b97\u7b26\u3002\n <\/div>\n
\n
var <\/span>x = 20; \nvar <\/span>y = 40; \nx = y;\nconsole.log<\/span>(\"After assignment the value of x is:  \"<\/span> + x); \nx += y; \nconsole.log<\/span>(\"x+=y: \"<\/span> + x); \nx-= y; \nconsole.log<\/span>(\"x-=y: \"<\/span> + x); \nx *= y; \nconsole.log<\/span>(\"x*=y: \"<\/span> + x); \nx \/= y; \nconsole.log<\/span>(\"x\/=y: \"<\/span> + x); \nx %= y; \nconsole.log<\/span>(\"x%=y: \"<\/span> + x);<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n
After assignment the value of x is:  40 \nx+=y: 80\nx-=y: 40\nx*=y: 1600\nx\/=y: 40\nx%=y: 0<\/pre>\n

<\/code>\n <\/div>\n

\u6309\u4f4d\u8fd0\u7b97\u7b26<\/h3>\n
\n \u6309\u4f4d\u8fd0\u7b97\u7b26\u7528\u4e8e\u5bf9\u6d89\u53ca\u5355\u4e2a\u4f4d\u64cd\u4f5c\u7684\u4e8c\u8fdb\u5236\u6570\u5b57\u6216\u4f4d\u6a21\u5f0f\u6267\u884c\u6309\u4f4d\u8fd0\u7b97\u3002\u6309\u4f4d\u8fd0\u7b97\u7b26\u5bf9\u53c2\u6570\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u6267\u884c\u64cd\u4f5c\n <\/div>\n
\n \u901a\u5e38\uff0c\u6309\u4f4d\u8fd0\u7b97\u7b26\u4f7f\u7528\u8f83\u5c11\uff0c\u4e0e\u5e94\u7528\u7a0b\u5e8f\u548c\u9ad8\u6027\u80fd\u7a0b\u5e8f\u76f8\u5173\u3002\n <\/div>\n\n\n\n\n\n\n\n\n\n\n
\u64cd\u4f5c\u5458<\/td>\n\u8bf4\u660e<\/td>\n<\/tr>\n
\u6309\u4f4d\u4e0e(&)<\/td>\n\u5b83\u5c06\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u7684\u6bcf\u4e00\u4f4d\u4e0e\u7b2c\u4e8c\u4e2a\u64cd\u4f5c\u6570\u7684\u76f8\u5e94\u4f4d\u8fdb\u884c\u6bd4\u8f83\u3002\u5982\u679c\u4e24\u4e2a\u4f4d\u90fd\u4e3a 1\uff0c\u5219\u7ed3\u679c\u4f4d\u5c06\u8bbe\u7f6e\u4e3a 1\uff0c\u5426\u5219\u5c06\u8bbe\u7f6e\u4e3a 0\u3002<\/td>\n<\/tr>\n
\u6309\u4f4d\u6216(|)<\/td>\n\u5b83\u5c06\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u7684\u6bcf\u4e00\u4f4d\u4e0e\u7b2c\u4e8c\u4e2a\u64cd\u4f5c\u6570\u7684\u76f8\u5e94\u4f4d\u8fdb\u884c\u6bd4\u8f83\u3002\u5982\u679c\u4e24\u4e2a\u4f4d\u90fd\u4e3a 0\uff0c\u5219\u7ed3\u200b\u200b\u679c\u4f4d\u5c06\u8bbe\u7f6e\u4e3a 0\uff0c\u5426\u5219\u5c06\u8bbe\u7f6e\u4e3a 1\u3001<\/td>\n<\/tr>\n
\u6309\u4f4d\u5f02\u6216(^)<\/td>\n\u5b83\u9700\u8981\u4e24\u4e2a\u64cd\u4f5c\u6570\uff0c\u5e76\u5bf9\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u6bcf\u4e00\u4f4d\u8fdb\u884c\u5f02\u6216\u3002\u5982\u679c\u4e24\u4e2a\u4f4d\u90fd\u4e0d\u540c\uff0c\u5219\u8fd4\u56de 1\uff0c\u5426\u5219\u8fd4\u56de 0\u3002<\/td>\n<\/tr>\n
\u6309\u4f4d\u975e(~)<\/td>\n\u5b83\u7ffb\u8f6c\u5176\u64cd\u4f5c\u6570\u7684\u4f4d\uff0c\u53730\u53d8\u4e3a1\uff0c1\u53d8\u4e3a0\u3002<\/td>\n<\/tr>\n
\u5de6\u79fb(<<)<\/td>\n\u5b83\u5c06\u5de6\u64cd\u4f5c\u6570\u7684\u503c\u5411\u5de6\u79fb\u52a8\u53f3\u64cd\u4f5c\u6570\u6307\u5b9a\u7684\u4f4d\u6570\u3002<\/td>\n<\/tr>\n
\u7b26\u53f7\u4f20\u64ad\u53f3\u79fb(>>)<\/td>\n\u5b83\u5c06\u5de6\u64cd\u4f5c\u6570\u7684\u503c\u5411\u53f3\u79fb\u52a8\u53f3\u64cd\u4f5c\u6570\u6307\u5b9a\u7684\u4f4d\u6570\u3002\u8fd9\u662f\u7b26\u53f7\u4f20\u64ad\uff0c\u56e0\u4e3a\u6211\u4eec\u4ece\u5de6\u8fb9\u6dfb\u52a0\u7684\u4f4d\u53d6\u51b3\u4e8e\u6570\u5b57\u7684\u7b26\u53f7(0 \u8868\u793a\u6b63\uff0c1 \u8868\u793a\u8d1f)\u3002 <\/td>\n<\/tr>\n
\u96f6\u586b\u5145\u53f3\u79fb<\/td>\n\u5b83\u63a5\u53d7\u4e24\u4e2a\u64cd\u4f5c\u6570\u3002\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u6307\u5b9a\u6570\u5b57\uff0c\u4e00\u4e2and \u7b2c\u4e8c\u4e2a\u8fd0\u7b97\u7b26\u786e\u5b9a\u8981\u79fb\u4f4d\u7684\u4f4d\u6570\u3002\u6bcf\u4e00\u4f4d\u90fd\u5411\u53f3\u79fb\u52a8\uff0c\u6ea2\u51fa\u7684\u4f4d\u5c06\u88ab\u4e22\u5f03\u3002\u56e0\u4e3a0\u4f4d\u662f\u4ece\u5de6\u8fb9\u6dfb\u52a0\u7684\uff0c\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u5b83\u662f\u4e00\u4e2a\u96f6\u586b\u5145\u53f3\u79fb\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u4f8b\u5982:\n <\/div>\n
\n \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86\u4e0a\u9762\u5217\u51fa\u7684\u6240\u6709\u903b\u8f91\u8fd0\u7b97\u7b26\u3002\n <\/div>\n
\n
var <\/span>x = 70; \/* 70 = 0100 0110 *\/\nvar <\/span>y = 80;  \/* 80 = 0101 0000 *\/\nvar <\/span>res = 0;\nconsole.log<\/span>(\"Value of 70 in binary 0100 0110\"<\/span> );\nconsole.log<\/span>(\"Value of 80 in binary 0101 0000\"<\/span> );\nres = x & y;       \/* 64 = 0100 0000 *\/\nconsole.log<\/span>(\"Value of x & y = %d\\n\"<\/span>, res );\nres = x | y;       \/* 86 = 0101 0110 *\/\nconsole.log<\/span>(\"Value of x |<\/span> y = %d\\n\", res );\nres = x ^ y;       \/* 22 = 0001 0110 *\/\nconsole.log<\/span>(\"Value of x ^ y = %d\\n\"<\/span>, res );\nres = ~x;          \/*-71 =-0100 0111 *\/\nconsole.log<\/span>(\"Value of ~ x = %d\\n\"<\/span>, res );\nres = x << 2;     \/* 280 = 1000 11000 *\/\nconsole.log<\/span>(\"Value of x << 2 = %d\\n\"<\/span>, res );\nres = x >> 2;     \/* 17 = 0001 0001 *\/\nconsole.log<\/span>(\"Value of x >> 2 = %d\\n\"<\/span>, res );<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n
Value of 70 in binary 0100 0110\nValue of 80 in binary 0101 0000\nValue of x & y = 64\nValue of x | y = 86\nValue of x ^ y = 22\nValue of ~ x =-71\nValue of x << 2 = 280\nValue of x >> 2 = 17<\/pre>\n

<\/code>\n <\/div>\n

\n \u6ce8\u610f: <\/span>\u8d4b\u503c\u8fd0\u7b97\u7b26\u7684\u903b\u8f91\u4e5f\u9002\u7528\u4e8e\u4f4d\u8fd0\u7b97\u7b26\uff0c\u6240\u4ee5\u5b83\u4eec\u53d8\u6210\u4e86<<=\u3001>>=\u3001&=\u3001|=\u3001^=\u3002\n <\/div>\n

\u6742\u9879\u8fd0\u7b97\u7b26<\/h3>\n
\n \u8fd9\u4e9b\u662f\u5728\u4e0d\u540c\u60c5\u51b5\u4e0b\u6267\u884c\u4e0d\u540c\u64cd\u4f5c\u7684\u8fd0\u7b97\u7b26\u3002\n <\/div>\n\n\n\n\n\n\n
\u8fd0\u8425\u5546<\/td>\n\u8bf4\u660e<\/td>\n<\/tr>\n
+(\u8fde\u63a5\u8fd0\u7b97\u7b26)<\/td>\n\u5b83\u9002\u7528\u4e8e\u5b57\u7b26\u4e32\u5e76\u5c06\u7b2c\u4e8c\u4e2a\u5b57\u7b26\u4e32\u9644\u52a0\u5230\u7b2c\u4e00\u4e2a\u3002<\/td>\n<\/tr>\n
-(\u5426\u5b9a\u8fd0\u7b97\u7b26)<\/td>\n\u5b83\u6539\u53d8\u4e86\u503c\u7684\u7b26\u53f7\u3002<\/td>\n<\/tr>\n
\uff1f(\u6761\u4ef6\u8fd0\u7b97\u7b26)<\/td>\n\u7528\u4e8e\u8868\u793a\u6761\u4ef6\u8868\u8fbe\u5f0f\u3002\u5b83\u4e5f\u88ab\u79f0\u4e3a\u4e09\u5143\u8fd0\u7b97\u7b26\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u8ba9\u6211\u4eec\u8bd5\u7740\u8be6\u7ec6\u4e86\u89e3\u4e00\u4e0b\u6742\u9879\u64cd\u4f5c\u7b26:\n <\/div>\n

\u5426\u5b9a\u64cd\u4f5c\u7b26(-)<\/h3>\n
\n \u7528\u6765\u6539\u53d8\u7b26\u53f7\n <\/div>\n
\n \u4f8b\u5982:\n <\/div>\n
\n
var <\/span>num1 = 80;\nvar <\/span>num2 =-num1;\nconsole.log<\/span>(\"Value of num1 = \"<\/span> +num1); \/\/ It will give 80<\/span>\nconsole.log<\/span>(\"Value of num2 = \"<\/span> +num2); \/\/ It will give-80<\/span><\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n
Value of num1 = 80\nValue of num2 =-80<\/pre>\n

<\/code>\n <\/div>\n

\u8fde\u63a5\u8fd0\u7b97\u7b26(+)<\/h3>\n
\n \u5b83\u5e94\u7528\u4e8e\u5b57\u7b26\u4e32\u5e76\u5c06\u7b2c\u4e8c\u4e2a\u5b57\u7b26\u4e32\u9644\u52a0\u5230\u7b2c\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u4f8b\u5b50\u6765\u7406\u89e3:\n <\/div>\n
\n \u4f8b\u5b50:\n <\/div>\n
\n
var <\/span>str1 = 'Hello'<\/span> + 'World'<\/span>;\nvar <\/span>str2 = 'Welcome '<\/span> + 'Back'<\/span>;\nconsole.log<\/span>(str1);\nconsole.log<\/span>(str2);<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n
HelloWorld\nWelcome Back<\/pre>\n

<\/code>\n <\/div>\n

\n \u8fde\u63a5\u8fd0\u7b97\u7b26\u4e0d\u4f1a\u5728\u5b57\u7b26\u4e32\u4e4b\u95f4\u6dfb\u52a0\u7a7a\u683c\u3002\u5b83\u5728\u5355\u4e2a\u8bed\u53e5\u4e2d\u8fde\u63a5\u591a\u4e2a\u5b57\u7b26\u4e32\u3002\u5982\u679c\u8981\u663e\u793a\u5b57\u7b26\u4e32\u4e4b\u95f4\u7684\u7a7a\u683c\uff0c\u5219\u5fc5\u987b\u624b\u52a8\u5b9a\u4e49\u5b83\u3002\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u5b57\u7b26\u4e32 \"HelloWorld\" \u4e0d\u5305\u542b\u4efb\u4f55\u7a7a\u683c\uff0c\u4f46\u7b2c\u4e8c\u4e2a\u5b57\u7b26\u4e32 \"Welcome Back\" \u6709\u7a7a\u683c\uff0c\u56e0\u4e3a\u6211\u4eec\u624b\u52a8\u6dfb\u52a0\u4e86\u5b83\u3002\n <\/div>\n

\u6761\u4ef6\u8fd0\u7b97\u7b26(?)<\/h3>\n
\n \u6b64\u8fd0\u7b97\u7b26\u8868\u793a\u6761\u4ef6\u8868\u8fbe\u5f0f\u3002\u5b83\u4e5f\u88ab\u79f0\u4e3a'\u4e09\u5143\u8fd0\u7b97\u7b26'\u3002\n <\/div>\n
\n \u8bed\u6cd5:\n <\/div>\n
\n
variablename = (condition) ? value1 : value2<\/pre>\n

<\/code>\n <\/div>\n

\n Where,\n <\/div>\n
\n condition: \u6307\u7684\u662f\u6761\u4ef6\u8868\u8fbe\u5f0f\u3002\n <\/div>\n
\n value1: \u5982\u679c\u6761\u4ef6\u4e3a\u771f\uff0c\u5219\u8fd4\u56de\u6b64\u503c\u3002\n <\/div>\n
\n value2: \u5982\u679c\u6761\u4ef6\u4e3a\u5047\uff0c\u5219\u8fd4\u56de\u6b64\u503c\u3002\n <\/div>\n
\n <\u5f3a>
\n \u793a\u4f8b:
\n <\/\u5f3a>\n <\/div>\n
\n
var <\/span>num1 = 30;\nvar <\/span>num2 = 20;\nvar <\/span>res = num1 > num2 ? \"Yes 30 is greater than 20\"<\/span> : \"No It'<\/span>s not\";\nconsole.log<\/span>(res);<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n
Yes 30 is greater than 20<\/pre>\n

<\/code>\n <\/div>\n

\u7c7b\u578b\u8fd0\u7b97\u7b26<\/h3>\n
\n \u662f\u4e00\u5143\u8fd0\u7b97\u7b26\uff0c\u8fd4\u56de\u64cd\u4f5c\u6570\u7684\u6570\u636e\u7c7b\u578b\u3002\n <\/div>\n
\n \u8bed\u6cd5:\n <\/div>\n
\n
typeof(operand)<\/pre>\n

<\/code>\n <\/div>\n

\n \u60a8\u53ef\u4ee5\u5728\u4e0b\u8868\u4e2d\u770b\u5230typeof \u8fd0\u7b97\u7b26\u8fd4\u56de\u7684\u6570\u636e\u7c7b\u578b\u548c\u503c\u5728 JavaScript \u4e2d:\n <\/div>\n\n\n\n\n\n\n\n
\u7c7b\u578b<\/td>\ntypeof \u8fd4\u56de\u7684\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n
String<\/td>\n\"\u5b57\u7b26\u4e32\"<\/td>\n<\/tr>\n
Boolean<\/td>\n\"\u5e03\u5c14\u503c\"<\/td>\n<\/tr>\n
Number<\/td>\n\"\u6570\u5b57\"<\/td>\n<\/tr>\n
Object<\/td>\n\"\u5bf9\u8c61\"<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\n \u793a\u4f8b:\n <\/div>\n
\n
var <\/span>a = 20;\nvar <\/span>b = true<\/span><\/span>;\nvar <\/span>c = 'Hello'<\/span>;\nvar <\/span>d = 'true'<\/span>;\nvar <\/span>e;\nconsole.log<\/span>(\"Variable a is \"<\/span> +typeof(a));\nconsole.log<\/span>(\"Variable b is \"<\/span> +typeof(b));\nconsole.log<\/span>(\"Variable c is a \"<\/span> +typeof(c));\nconsole.log<\/span>(\"Variable d is a \"<\/span> +typeof(d));\nconsole.log<\/span>(\"Variable e is \"<\/span> +typeof(e));<\/pre>\n

<\/code>\n <\/div>\n

\n \u8f93\u51fa:\n <\/div>\n
\n
Variable a is number\nVariable b is boolean\nVariable c is a string\nVariable d is a string\nVariable e is undefined<\/pre>\n

<\/code>\n <\/div>\n

\n \u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u53d8\u91cfe\u6ca1\u6709\u5b9a\u4e49(\u6216\u6ca1\u6709\u521d\u59cb\u5316)\uff1b\u8fd9\u5c31\u662f typeof \u8fd0\u7b97\u7b26\u7ed9\u5b83\u7684\u7c7b\u578b undefined \u7684\u539f\u56e0\u3002\n <\/div>\n
\n \u5982\u679c\u60a8\u5728\u5f15\u53f7\u5185\u4f7f\u7528\u5e03\u5c14\u503c\uff0c\u90a3\u4e48\u5b83\u4eec\u5c06\u88ab\u89c6\u4e3a\u5b57\u7b26\u4e32\uff0c\u5982\u60a8\u6240\u89c1 >\u53d8\u91cf\"d\"\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\u3002\n <\/div>\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"ES6 \u8fd0\u7b97\u7b26zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[161],"tags":[],"class_list":["post-1909","post","type-post","status-publish","format-standard","hentry","category-es6jc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1909"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=1909"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/1909\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=1909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=1909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=1909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}