Hello AlexParas,
thank you for your very helpful comments. I fixed my post according to your recommendations.
Regards
Ouzo69
Hello AlexParas,
thank you for your very helpful comments. I fixed my post according to your recommendations.
Regards
Ouzo69
It was just a cooperative comment from student to student. Again nice homework and glad to see that you correspond and agreed to it.
My best regards
Operations are like actions in the code. If you put an operator between two values, it will apply the operator to those values and produce a new value. Operators can be, for example, arithmetic actions, such as multiplying, adding, subtracting or dividing.
Binary operators use two values and include e.g.: +, −, *, / , %, <, >, <=, >=, ==, !=, &&, l l
Logical operators: &&, l l, !
What are operators?
signs used in setting variables, checking value in comparison to another and mathematical operations
What binary operators do you know?
Operators are symbols that are used with variables to perform certain functions.
You can think for example of arithmetic functions, such as: addition, subtraction and multiplication.
+, -, *, /, %, ==, ===, !=, !==, >, <, >=, <=, ?, &&, ||, !
JavaScript supports three logical operators:
and &&
or ||
not !
The +
operator adds two numbers.
EXAMPLE
1 + 2;
OUTPUT
3
The -
operator subtracts one number from another.
EXAMPLE
50 - 15;
OUTPUT
35
The *
operator multiplies two numbers. Notice it’s an asterisk and not the × symbol commonly used in math.
EXAMPLE
3 * 12;
OUTPUT
36
The /
operator divides one number by another. Notice it’s a forward slash and not the ÷ symbol commonly used in math.
EXAMPLE
12 / 4;
OUTPUT
3
JavaScript expressions follow an order of operations, so even though +
is written first in the following example, the multiplication happens first between the last two numbers and *
.
EXAMPLE
1 + 100 * 5;
OUTPUT
501
If want more control over the order, that’s where the grouping operator comes in handy.
()
operator groups other values and operations. Code located between parentheses evaluates first as JavaScript solves each operation moving from left to right.
Adding the grouping operator to the previous example causes 1 + 100 to evaluate first.
EXAMPLE
(1 + 100) * 5;
OUTPUT
505
The +
operator can also concatenate strings, which is another way of saying it can add them together.
EXAMPLE
"news" + "paper";
OUTPUT
"newspaper"
The =
operator assigns values. It’s used for setting the value of variables.
EXAMPLE
var dinner = "sushi";
operand1 operator operand2
3+4
or x*y
. [/spoiler][spoiler] A unary operator requires a single operand, either before or after the operator:
operator operand
or
operand operator
For example, x++
or ++x
.
[/spoiler]
||
(OR), &&
(AND), !
(NOT).[/spoiler][spoiler]
Operator | Syntax | Description |
---|---|---|
Logical AND ( && ) |
expr1 && expr2 |
If expr1 can be converted to true , returns expr2 ; else, returns expr1 . |
Logical OR ( || ) |
expr1 || expr2 |
If expr1 can be converted to true , returns expr1 ; else, returns expr2 . |
Logical NOT ( ! ) |
!expr |
Returns false if its single operand can be converted to true ; otherwise, returns true . |
[/spoiler]
[spoiler]In modern code you can use the new Nullish coalescing operator
( ??
) that works like ||
, but it only returns the second expression, when the first one is nullish, i.e. null or undefined. It is thus the better alternative to provide defaults, when values like ''
or 0
are valid values for the first expression, too.[/spoiler]
Operators are symbols that tell the program what to do with various values within the program to accomplish a certain function. For exapmle +, -, ect.
That are operators that use 2 values.
Binary operators for JS Arithmatic operators (+, -, *, /, and %), string concatenation (+), comparison (==, !=, ===, !==, <, >, <=, >=)
Logical operators are used to determine the logic between variables or values.
&& (and), ||(or), !(not)
Thank you for contributing & helping our community. We need more active people like you in the forum, we appreciate it very much.
keep it up!
Ivo
Wow, I didn’t see the arrows at first, and I was like “booorriiiii”, but then I saw the arrows and I got my mind blown away!
Nice touch with the examples etc, etc… and the answers of course.
Ivo
Glenn_CostaRica
1. What are operators?
Operators are sets of instructions that execute some work on the values of one or more variables. In reality, operators are functions, but, as programmers, we interact with them as simple symbols like !, +, or * (not, addition or multiplication).
2. What binary operators do you know?
==, ===, !=, !==, <, >, <=, >=, &&, ||, +, -, *, /, ^ , % …
3. What logical operators do you know?
&&, ||, !..
1. What are operators?
Operators compare a value and return true or false.
2. What binary operators do you know?
> greater than
< less than
== equal to
<= less than or equal to
>= more than or equal to
!= not equal to
3. What logical operators do you know?
&& and
|| or
? conditional
1. What are operators?
Binary and Unary operators exist. Binary operators take two values, Unary operators take a single value. Operator carry out some action on the values they are given.
2. What binary operators do you know?
Arithmetic operations would be binary operators, such as, add, minus, divide, multiply. Boolean operators like, greater than, less than, ==, !==, are also binary operators.
3. What logical operators do you know?
Logical operator would be, and, or, not, and used with 2 values return boolean result.
1. What are operators?
Operators conduct operations / actions such as arithmetic (+ - * /) on values to evaluate expressions and solve problems.
2. What binary operators do you know?
"yes" or "no", "on" or "off", "true" or "false"
3. What logical operators do you know?
and = &&, or = ||, not = !=
Operators are values that are used to solve mathematical problems for example: +, -, *, /
Binary operators are operators that take two values. Binary operators are presented in this form: Operand1 Operator Operand2 (4 > 3, 4 + 5 etc). Commonly used operators are ==, !=, <, >, <=, >=, +, -, *, /, &&, ||, %
.
The operator “&&” represents logical and if the two operands are true then the output will be true.
The operator “||” represents logical or if one operand is true then the output will be true.
The unary operator “!” Not that changes true to false and false to true.
The ternary operator(which is the only ternary operator in the language) for example console.log(true ? 3 : 4);
if true is typed then the value in the center gets “picked” and if false is typed the value on the right gets “picked”.