filmov
tv
Operators and Expressions in JavaScript - #5 @Everyday-Be-Coding

Показать описание
In JavaScript, operators and expressions are fundamental concepts that enable you to perform operations on data. Operators are symbols that perform operations on operands, and expressions are combinations of operators, operands, and variables that evaluate to a single value. Let's explore these concepts further:
Operators:
Arithmetic Operators: Perform arithmetic operations like addition, subtraction, multiplication, division, and modulus.
Example
let result = 10 + 5; // Addition
result = 10 - 5; // Subtraction
result = 10 * 5; // Multiplication
result = 10 / 5; // Division
result = 10 % 3; // Modulus (remainder)
Assignment Operators: Assign values to variables.
Example:
let x = 5;
x += 3; // Equivalent to: x = x + 3;
Comparison Operators: Compare two values and return a Boolean result.
Example
let isEqual = (5 === 5); // Strict equality (true)
let isGreater = (10 5); // Greater than (true)
Logical Operators: Perform logical operations such as AND, OR, and NOT.
Example
let result = (true && false); // AND (false)
result = (true || false); // OR (true)
result = !true; // NOT (false)
Unary Operators: Operators that take a single operand.
Example
let x = 5;
x++; // Increment
x--; // Decrement
Ternary Operator (Conditional Operator): A shorthand for an if-else statement.
Example
let result = (5 Greater-than 3) ? "Yes" : "No";
Bitwise Operators: Perform bitwise operations on operands.
Example
let result = 5 & 3; // Bitwise AND
result = 5 | 3; // Bitwise OR
Expressions:
Arithmetic Expressions:
Example
let result = (5 * 2) + (10 / 2);
Logical Expressions:
Example
let isTrue = (true && false) || (true && true);
Conditional Expressions:
Example
let result = (5 Greater-than 3) ? "Yes" : "No";
Assignment Expressions:
Example:
let x = 5;
x += 3; // Equivalent to: x = x + 3;
Function Call Expressions:
Example:
function add(a, b) {
return a + b;
}
let sum = add(3, 5);
Array and Object Expressions:
Example:
let array = [1, 2, 3];
let obj = { name: "John", age: 30 };
Operators and expressions are fundamental to JavaScript programming and are used extensively in writing algorithms, conditions, and calculations. Understanding how to use them effectively is essential for writing concise and efficient code.
Chapter :
00:00 Introduction to Operators
00:20 Arithmetic Operators
00:40 Assignment Operators
00:54 Comparison Operators
01:10 Logical Operators
01:23 Unary Operators
01:36 Ternary Operator
01:48 Bitwise Operators
01:56 Arithmetic Expressions
02:12 Logical Expressions
02:22 Conditional Expressions
02:29 Assignment Expressions
02:36 Function Call Expressions
02:46 Array & Object Expressions
02:56 Summery
Thank you for watching this video.
EVERYDAY BE CODING
Operators:
Arithmetic Operators: Perform arithmetic operations like addition, subtraction, multiplication, division, and modulus.
Example
let result = 10 + 5; // Addition
result = 10 - 5; // Subtraction
result = 10 * 5; // Multiplication
result = 10 / 5; // Division
result = 10 % 3; // Modulus (remainder)
Assignment Operators: Assign values to variables.
Example:
let x = 5;
x += 3; // Equivalent to: x = x + 3;
Comparison Operators: Compare two values and return a Boolean result.
Example
let isEqual = (5 === 5); // Strict equality (true)
let isGreater = (10 5); // Greater than (true)
Logical Operators: Perform logical operations such as AND, OR, and NOT.
Example
let result = (true && false); // AND (false)
result = (true || false); // OR (true)
result = !true; // NOT (false)
Unary Operators: Operators that take a single operand.
Example
let x = 5;
x++; // Increment
x--; // Decrement
Ternary Operator (Conditional Operator): A shorthand for an if-else statement.
Example
let result = (5 Greater-than 3) ? "Yes" : "No";
Bitwise Operators: Perform bitwise operations on operands.
Example
let result = 5 & 3; // Bitwise AND
result = 5 | 3; // Bitwise OR
Expressions:
Arithmetic Expressions:
Example
let result = (5 * 2) + (10 / 2);
Logical Expressions:
Example
let isTrue = (true && false) || (true && true);
Conditional Expressions:
Example
let result = (5 Greater-than 3) ? "Yes" : "No";
Assignment Expressions:
Example:
let x = 5;
x += 3; // Equivalent to: x = x + 3;
Function Call Expressions:
Example:
function add(a, b) {
return a + b;
}
let sum = add(3, 5);
Array and Object Expressions:
Example:
let array = [1, 2, 3];
let obj = { name: "John", age: 30 };
Operators and expressions are fundamental to JavaScript programming and are used extensively in writing algorithms, conditions, and calculations. Understanding how to use them effectively is essential for writing concise and efficient code.
Chapter :
00:00 Introduction to Operators
00:20 Arithmetic Operators
00:40 Assignment Operators
00:54 Comparison Operators
01:10 Logical Operators
01:23 Unary Operators
01:36 Ternary Operator
01:48 Bitwise Operators
01:56 Arithmetic Expressions
02:12 Logical Expressions
02:22 Conditional Expressions
02:29 Assignment Expressions
02:36 Function Call Expressions
02:46 Array & Object Expressions
02:56 Summery
Thank you for watching this video.
EVERYDAY BE CODING