Operands and operators are the fundamental building blocks of JavaScript (and by association, most programming languages). Used together, they form expressions, the basic computing unit. While the names may sound technical and intimidating, they’re really not:
Operators are the verbs of JavaScript: they are symbols that allow operations, such as addition and subtraction, to take place. Some operators are words, but most are the symbols you’re already familiar with from learning math as a child. Others are more complex, or combinations of symbols, which we’ll get to presently.
Operands are the things that are acted upon by operators. They are typically positioned either side of an operand to form an expression. For this reason, you’ll sometimes hear them referred to as “left-hand operands” (or “left operand”) and “right-hand operands” (or “right operand”), describing their position in the expression. For example:
var x = 5;
In this case, the equals sign is an operator, and the x
and 5
are operands (the left and right-hand operands, respectively. Of course, x
also signifies a variable in this instance). Taken together, they form an expression.
Operators can do many things to operands: compare them, increment them, decrement them, divide them, and more. Conventionally, they are grouped together as arithmetic operators, bitwise operators, assignment operators, increment operators, comparison operators and logical operators, along with a collection of others. Each of them will be covered as separate entries in this reading list.
Photograph by Xtef Mistik, licensed under Creative Commons.
Enjoy this piece? I invite you to follow me at twitter.com/dudleystorey to learn more.