JavaScript中的运算符是什么?
让我们采用一个简单的表达式“4+5等于9”。这里4和5称为操作数,“+”称为运算符。
JavaScript支持以下类型的运算符。
算术运算符
比较运算符
逻辑(或关系)运算符
赋值运算符
条件(或三元)运算符
这是一个说明运算符示例的示例-
<html> <body> <script> var a = 33; var b = 10; var c = "Test"; var linebreak = "<br />"; document.write("a + b = "); result = a + b; document.write(result); document.write(linebreak); document.write("a - b = "); result = a - b; document.write(result); document.write(linebreak); document.write("a / b = "); result = a / b; document.write(result); document.write(linebreak); document.write("a % b = "); result = a % b; document.write(result); document.write(linebreak); document.write("a + b + c = "); result = a + b + c; document.write(result); document.write(linebreak); a = ++a; document.write("++a = "); result = ++a; document.write(result); document.write(linebreak); b = --b; document.write("--b = "); result = --b; document.write(result); document.write(linebreak); </script> </body> </html>