{"id":3012,"date":"2019-06-12T00:44:05","date_gmt":"2019-06-12T00:44:05","guid":{"rendered":"http:\/\/softlect.in\/?p=3012"},"modified":"2019-06-12T01:11:01","modified_gmt":"2019-06-12T01:11:01","slug":"javascript-operators","status":"publish","type":"post","link":"http:\/\/softlect.com\/index.php\/javascript-operators\/","title":{"rendered":"JavaScript &#8211; Operators"},"content":{"rendered":"<p><strong>JavaScript Operators<\/strong><\/p>\n<p>An operator in javascript is a symbol or keyword that performs some sort of calculation. JavaScript uses different types of operators:<\/p>\n<p>Arithmetic<\/p>\n<p>Assignment<\/p>\n<p>Comparison<\/p>\n<p>Logical<\/p>\n<p>Bitwise<\/p>\n<p>Special<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Arithmetic Operators:<\/strong><\/p>\n<p>Addition (+), subtraction (-), multiplication (*), Division (\/), modulus (%), increment (++) pre and post, decrement (&#8211;) pre and post<\/p>\n<p>Type coercion is attempting to change the data type when deemed necessary.<\/p>\n<p>var x = 10; Number<\/p>\n<p>var y = 1.23; Decimal<\/p>\n<p>document.write(x+y) will display 11.23 result is decimal<\/p>\n<p>&nbsp;<\/p>\n<p>var x = 10; Number<\/p>\n<p>var y = \u201c1\u201d; String<\/p>\n<p>document.write(x+y) will display 101 result is string<\/p>\n<p>&nbsp;<\/p>\n<p>Unary +<\/p>\n<p>var x = 10; Number<\/p>\n<p>var y = \u201c1\u201d; String<\/p>\n<p>var z = x + (+y); the y string is coerce in to number and result is 11<\/p>\n<p><strong>Assignment Operators<\/strong><\/p>\n<p>= , += , -= , *= , \/= , %=<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Comparison Operators<\/strong><\/p>\n<p>== example 4==3 false \u201c4\u201d == 4 is true coercion, 1 = true is true, \u201ccar\u201d == \u201cCar\u201d false<\/p>\n<p>!= not equal to<\/p>\n<p>=== (strict equal to) true if both sides are equal and of same type (no coercion is performed)<\/p>\n<p>!== (strict not equal to)<\/p>\n<p>&gt;<\/p>\n<p>&lt;<\/p>\n<p>&gt;=<\/p>\n<p>&lt;=<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Logical Operators<\/strong><\/p>\n<p>&amp;&amp;<\/p>\n<p>||<\/p>\n<p>!<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Bitwise Operators<\/strong><\/p>\n<p>&amp;<\/p>\n<p>|<\/p>\n<p>^ XOR<\/p>\n<p>~ not<\/p>\n<p>&lt;&lt; Left shift<\/p>\n<p>&gt;&gt; right shift<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Special Operators<\/strong><\/p>\n<p>?: conditional\u00a0\u00a0 x&lt;y?10:20<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript Operators An operator in javascript is a symbol or keyword that performs some sort of calculation. JavaScript uses different types of operators: Arithmetic Assignment Comparison Logical Bitwise Special &nbsp;&hellip; <\/p>\n","protected":false},"author":1,"featured_media":3039,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[78],"tags":[],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/posts\/3012"}],"collection":[{"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/comments?post=3012"}],"version-history":[{"count":2,"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/posts\/3012\/revisions"}],"predecessor-version":[{"id":3053,"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/posts\/3012\/revisions\/3053"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/media\/3039"}],"wp:attachment":[{"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/media?parent=3012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/categories?post=3012"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/softlect.com\/index.php\/wp-json\/wp\/v2\/tags?post=3012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}