{"id":13,"date":"2007-05-20T23:58:11","date_gmt":"2007-05-21T03:58:11","guid":{"rendered":"http:\/\/prglab.com\/blog\/?page_id=13"},"modified":"2007-08-25T14:59:12","modified_gmt":"2007-08-25T18:59:12","slug":"js-operators","status":"publish","type":"page","link":"https:\/\/www.prglab.com\/blog\/js-tutorial\/js-operators","title":{"rendered":"JavaScript\u4e2d\u7684\u64cd\u4f5c\u7b26"},"content":{"rendered":"<p>\u7b80\u5355\u5217\u4e00\u4e0b\u8868\uff0c\u5c31\u4e0d\u591a\u505a\u89e3\u91ca\u4e86\uff0c\u57fa\u672c\u548c\u5176\u4ed6\u8bed\u8a00\u6ca1\u6709\u592a\u5927\u533a\u522b<\/p>\n<p><strong>\u7b97\u672f\u64cd\u4f5c\u7b26<\/strong><br \/>\n+, -, *, \/, %(\u6a21\u8fd0\u7b97\uff0c\u5373\u9664\u6cd5\u53d6\u4f59), ++, &#8211; &#8211;<br \/>\n\u5c31\u4e0d\u591a\u8bf4\u4e86<\/p>\n<p><strong>\u8d4b\u503c\u64cd\u4f5c\u7b26<\/strong><\/p>\n<ul>\n<li>= \tx=y<\/li>\n<li>+= \tx+=y \u76f8\u5f53\u4e8e x=x+y<\/li>\n<li>-= \tx-=y  \u76f8\u5f53\u4e8e  x=x-y<\/li>\n<li>*= \tx*=y \u76f8\u5f53\u4e8e x=x*y<\/li>\n<li>\/= \tx\/=y \u76f8\u5f53\u4e8e x=x\/y<\/li>\n<li>%= \tx%=y \u76f8\u5f53\u4e8e x=x%y<\/li>\n<\/ul>\n<p><strong>\u6bd4\u8f83\u64cd\u4f5c\u7b26<\/strong><\/p>\n<ul>\n<li>== \t\u7b49\u4e8e\uff08\u53ea\u68c0\u67e5\u503c\uff09\uff0c \u4f8b\u5982\uff1a5==8 \u8fd4\u56de\u5047<\/li>\n<li>=== \t\u7b49\u4e8e \uff08\u8fd9\u4e2a\u6bd4\u8f83\u7279\u6b8a\uff0c\u503c\u548c\u7c7b\u578b\u90fd\u8981\u68c0\u67e5\uff09\uff0c\u4f8b\u5982\uff1a<br \/>\nx=5<br \/>\ny=&#8221;5&#8243;<br \/>\nx==y \u8fd4\u56de\u771f<br \/>\nx===y \u8fd4\u56de\u5047<\/li>\n<li>!= \t\u4e0d\u7b49\u4e8e\uff0c\u4f8b\u5982\uff1a5!=8 \u8fd4\u56de\u771f<\/li>\n<li>&gt; \t\u5927\u4e8e\uff0c\u4f8b\u5982\uff1a5&gt;8 \u8fd4\u56de\u5047<\/li>\n<li>&lt; \t\u5c0f\u4e8e\uff0c\u4f8b\u5982\uff1a5&lt;8 \u8fd4\u56de\u771f<\/li>\n<li>&gt;= \t\u5927\u4e8e\u7b49\u4e8e\uff0c\u4f8b\u5982\uff1a5&gt;=8 \u8fd4\u56de\u5047<\/li>\n<li>&lt;= \t\u5c0f\u4e8e\u7b49\u4e8e\uff0c\u4f8b\u5982\uff1a5&lt;=8 \u8fd4\u56de\u771f<\/li>\n<\/ul>\n<p><strong>\u903b\u8f91\u9884\u7b97\u7b26<\/strong><br \/>\n&amp;&amp;\uff08\u4e0e\uff09\uff0c||\uff08\u6216\uff09\uff0c\uff01\uff08\u975e\uff09\u3002\u4e0d\u591a\u8bf4\u4e86<\/p>\n<p><strong>\u5b57\u7b26\u4e32\u64cd\u4f5c\u7b26<\/strong><br \/>\n\u5b57\u7b26\u4e32\u901a\u5e38\u4e3a\u6587\u672c\u5185\u5bb9\uff0c\u4f8b\u5982&#8221;Hello World!&#8221;\u3002JS\u4f7f\u7528+\u64cd\u4f5c\u7b26\u6765\u5c06\u4e24\u4e2a\u5b57\u7b26\u4e32\u8fde\u63a5\u5728\u4e00\u8d77\u3002\u4f8b\u5982\uff1a<\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">txt1=&#8221;What a very&#8221;<br \/>\ntxt2=&#8221;nice day!&#8221;<br \/>\ntxt3=txt1+txt2<\/td>\n<\/tr>\n<\/table>\n<p>\u73b0\u5728\u53d8\u91cftxt3\u7684\u503c\u4e3a&#8221;What a verynice day!&#8221;\u3002<\/p>\n<p>\u8981\u5728\u4e24\u4e2a\u5b57\u7b26\u4e32\u53d8\u91cf\u4e2d\u95f4\u52a0\u4e00\u4e2a\u7a7a\u683c\uff0c\u53ef\u4ee5\u5728\u4e0a\u9762\u7684\u8868\u8fbe\u5f0f\u4e2d\u63d2\u5165\u4e00\u4e2a\u7a7a\u683c\uff0c\u6216\u5728\u5176\u4e2d\u4e00\u4e2a\u5b57\u7b26\u4e32\u4e0a\u52a0\u4e00\u4e2a\u7a7a\u683c\u3002\u4f8b\u5982\uff1a<\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">txt1=&#8221;What a very&#8221;<br \/>\ntxt2=&#8221;nice day!&#8221;<br \/>\ntxt3=txt1+&#8221; &#8220;+txt2<\/td>\n<\/tr>\n<\/table>\n<p>\u6216\u8005<\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">txt1=&#8221;What a very &#8221;<br \/>\ntxt2=&#8221;nice day!&#8221;<br \/>\ntxt3=txt1+txt2<\/td>\n<\/tr>\n<\/table>\n<p>\u73b0\u5728\u53d8\u91cftxt3\u7684\u503c\u4e3a&#8221;What a very nice day!&#8221;\u3002<\/p>\n<p><strong>\u6761\u4ef6\u64cd\u4f5c\u7b26<\/strong><\/p>\n<p>JavaScript \u4e5f\u6709\u4e00\u4e2a\u6761\u4ef6\u64cd\u4f5c\u7b26\uff0c\u53ef\u4ee5\u7528\u6765\u6839\u636e\u6761\u4ef6\u7ed9\u53d8\u91cf\u8d4b\u503c<\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">variablename=(condition)?value1:value2<\/td>\n<\/tr>\n<\/table>\n<p>\u4f8b\u5b50\uff1a<\/p>\n<table align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"96%\">\n<tr>\n<td class=\"quote\">greeting=(visitor==&#8221;PRES&#8221;)?&#8221;Dear President &#8220;:&#8221;Dear &#8220;<\/td>\n<\/tr>\n<\/table>\n<p>\u5982\u679c\u53d8\u91cfvisitor\u7b49\u4e8ePRES\uff0c\u5219\u628a\u5b57\u7b26\u4e32&#8221;Dear President &#8220;\u8d4b\u7ed9\u53d8\u91cfgreeting\uff0c\u5426\u5219\uff0c\u628a\u5b57\u7b26\u4e32&#8221;Dear &#8220;\u8d4b\u7ed9\u53d8\u91cfgreeting\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u5355\u5217\u4e00\u4e0b\u8868\uff0c\u5c31\u4e0d\u591a\u505a\u89e3\u91ca\u4e86\uff0c\u57fa\u672c\u548c\u5176\u4ed6\u8bed\u8a00\u6ca1\u6709\u592a\u5927\u533a\u522b \u7b97\u672f\u64cd\u4f5c\u7b26 +, -, *, \/, %(\u6a21\u8fd0\u7b97\uff0c\u5373\u9664\u6cd5\u53d6\u4f59), ++, &#8211; &#8211; \u5c31\u4e0d\u591a\u8bf4\u4e86 \u8d4b\u503c\u64cd\u4f5c\u7b26 = x=y += x+=y \u76f8\u5f53\u4e8e x=x+y -= x-=y \u76f8\u5f53\u4e8e x=x-y *= x*=y \u76f8\u5f53\u4e8e x=x*y \/= x\/=y \u76f8\u5f53\u4e8e x=x\/y %= x%=y \u76f8\u5f53\u4e8e x=x%y \u6bd4\u8f83\u64cd\u4f5c\u7b26 == \u7b49\u4e8e\uff08\u53ea\u68c0\u67e5\u503c\uff09\uff0c \u4f8b\u5982\uff1a5==8 \u8fd4\u56de\u5047 === \u7b49\u4e8e \uff08\u8fd9\u4e2a\u6bd4\u8f83\u7279\u6b8a\uff0c\u503c\u548c\u7c7b\u578b\u90fd\u8981\u68c0\u67e5\uff09\uff0c\u4f8b\u5982\uff1a x=5 y=&#8221;5&#8243; x==y \u8fd4\u56de\u771f x===y \u8fd4\u56de\u5047 != \u4e0d\u7b49\u4e8e\uff0c\u4f8b\u5982\uff1a5!=8 \u8fd4\u56de\u771f &gt; \u5927\u4e8e\uff0c\u4f8b\u5982\uff1a5&gt;8 \u8fd4\u56de\u5047 &lt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3,"menu_order":6,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/13"}],"collection":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":0,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/13\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/pages\/3"}],"wp:attachment":[{"href":"https:\/\/www.prglab.com\/blog\/wp-json\/wp\/v2\/media?parent=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}