- Operators are symbols or words used to signify the operations we want to perform on values.
- As binary operators are operators that use 2 values, almost all javascript arithmetic, relational, logical, string, comparison and assignment operators are binary. Exceptions include unary operators where only one value is used eg “typeof” and “-”.
- JavaScript supports three logical operators: and, or, and not. (&&, ||, !)
What are operators?
Operators are the simplest functions which operate with values (for example: +, -, *, /).
What binary operators do you know?
Multiplication, addition, subtraction, division, equality, etc…
What logical operators do you know?
And, or and not - &&, || and (!).
- operators are symbols that give variables a value
- binary operators are + - * / %
- logical operators are && || !
What are operators?
Operators provide an vast array of actions which can be performed on values in Javascript. For example you can assign a value to a variable with the = sign. You can subtract one number from another number with the - sign. You can also make comparisons with logical operators.
What binary operators do you know?
- = assignment operator
- + adition operator
- - subtracton operator
- * multiplication operator
- / division operator
- % modulus operator
- > greater than operator
- < less than operator
- == epual to operator
- != not equal to
What logical operators do you know?
I know the following logical operators
- && returns true if object a and b are true
- || returns true if either object a or b are true
- true/false ? 1 : 2 this one just picked up from the book a ternary conditional where the value on left of question mark picks from one value on the right. if true the value to left of colon is picked and if false the value on right. have used it before in demo code but never understood it till now.
Great analysis @AliasFresh!
Glad I helped there
Logical NOT (!
) and typeof
operators are also unary (not binary) operators — which makes sense if you think about it.
Nice work @Long
You may be interested to know that…
Logical NOT ( !
) and typeof
operators are unary (not binary) operators, because they only operate on one value (not two). Other examples of unary operators are ++
(increment operator) and --
(decrement operator), and you’ll come across those a bit later in the course.
Basically, whether unary, binary, ternary or logical etc… what all operators have in common is that they all perform different kinds of actions on values.
Great analysis @Beryl
Not sure if it was a slip or formatting error, but:
- // binary, arithmetic operator
-- // unary, decrement operator
Logical NOT (!
) is also a unary operator — which makes sense if you stop to think about it.
- What are operators?
Operators manipulate values *±/%??++ - What binary operators do you know?
relational,logical,string,comparison, arithmetic
operators that use two values are binary operators - What logical operators do you know?
And&&,orII,not!
- What are operators?
Operators are special symbols that help interact two values with each other in the program. -+/% = - What binary operators do you know?
< > == != && || * - What logical operators do you know?
and, not, or
NIce answers @LAVATOR
Just to add…
That’s right for binary operators… but operators can also perform an action on just one value (which can also be an expression). These are called unary operators:
The NOT (!
) operator is actually a unary operator, as well as a logical operator (which makes sense if you think about it). You’ll learn about some more of them later in the course (e.g. ++
and --
).
There is also something called a ternary operator that performs an action on 3 values. Look it up if you haven’t heard of it… it’s pretty cool
Yes thanks for that. I should have been more specific was referring to - being used as both as per pg 15 Eloquent JavaScript. “The minus operator can be used both as
a binary operator and as a unary operator.”
console.log(- (10 - 2))
// → -8
Ah, yes! I hadn’t thought of that…
I just meant the “double minus” decrement operator --
when referring to unary operators, but you’re right… and I should update my little summary to:
- // binary subtraction operator AND unary negation operator
-- // unary decrement operator
+ // binary addition operator AND unary plus operator
++ // unary increment operator
…it just never ends does it?..
It’s all here in its full glory, in the MDN web docs
What are operators?
- The + and * symbols are called operators—the first stands for addition, and the second stands for multiplication. Putting an operator between two values will apply it to those values and produce a new value.
- For subtraction, there is the - operator and division that can be done with the / operator.
What binary operators do you know?
- Binary operators for arithmetic are (+, -, *, /, and %).
What logical operators do you know?
- JavaScript supports three logical operators: and, or, and not. These can be used to “reason” about Booleans.
- The && operator represents logical and. It is a binary operator, and its result is true only if both the values given to it are true.
console.log(true && false)
// → false
console.log(true && true)
// → true
- The || operator denotes logical or. It produces true if either of the values given to it is true.
console.log(false || true)
// → true
console.log(false || false)
// → false
- Not is written as an exclamation mark (!). It is a unary operator that flips the value given to it—!true produces false, and !false gives true.
-
What are operators? The > and < signs are the traditional symbols for “is greater than” and “is
less than”, respectively. They are binary operators. -
What binary operators do you know? < >
-
What logical operators do you know? and, or, and not.
Hi @Jaysun,
Yes, that’s correct…but there are many more operators than just these comparison operators. In general, operators perform different actions on values.
- What are operators?
- An operator is a symbol that operates on a value or a variable
- What binary operators do you know?
- <, >
- What logical operators do you know?
- &&, ||, !
What are operators?
Operators are symbols used to express and interaction between two or more values
What binary operators do you know?
- //Add
- //Subtract
/ //Divided by
- //Multiple
% //Modulo
What logical operators do you know?
&& and
|| or
- Operators are symbols or words that interact with values in a function.
- Binary operators:
arithmetic + , - , *, / , %
string concatenation +
comparison == , != , === , !== , < , > , <= , >=
logic && , || - logical operators :* && , ||, !, conditional operator ? :
- Operators are terms that manipulate values to a desired, hopefully, outcome.
- String, Arithmetic, Comparison.
- “And, Or, Not”
1 - What are operators?
Operators are the symbols between values that allow different operations like addition, subtraction, multiplication, and more.
A
JavaScript Logical Operators:
Operator Description
&& logical and
|| logical or
! logical not
B
JavaScript Arithmetic Operators:
Operator Description
+ Addition
- Subtraction
* Multiplication
** Exponentiation (ES2016)
/ Division
% Modulus (Division Remainder)
++ Increment
-- Decrement
C
JavaScript String Operators:
Operator Description
+ concatenate strings
D
JavaScript Bitwise Operators:
Operator Description
& AND 5 & 1
| OR 5 | 1
~ NOT ~ 5
^ XOR 5 ^ 1
<< Zero fill left shift
>> Signed right shift
>>> Zero fill right shift
E
JavaScript Comparison Operators:
Operator Description
== equal to
=== equal value and equal type
!= not equal
!== not equal value or not equal type
> greater than
< less than
>= greater than or equal to
<= less than or equal to
? ternary operator
F
JavaScript Assignment Operators:
Operator Use Equivalent
= x = y x = y
+= x += y x = x + y
-= x -= y x = x - y
*= x *= y x = x * y
/= x /= y x = x / y
%= x %= y x = x % y
**= x **= y x = x ** y
G
JavaScript Type Operators:
Operator Description
typeof Returns the type of a variable
instanceof Returns true if an object is an instance of an object type
2 - What binary operators do you know?
Binary operators are the operators that use two objects like +, -, /, *, <, >, !=, etc..
ex: 1 + 2
3 - What logical operators do you know?
A
JavaScript Logical Operators:
Operator Description
&& logical and
|| logical or
! logical not