Sasco Jay Tech

Sasco Jay Tech I'm a Website developer

28/01/2025

Arithmetic operators in JavaScript are used to perform mathematical calculations. Here's a summary:

Basic Operators
1. Addition (+): Adds two numbers.
2. Subtraction (-): Subtracts one number from another.
3. Multiplication (*): Multiplies two numbers.
4. Division (/): Divides one number by another.
5. Modulus (%): Returns the remainder of division.
6. Exponentiation (**): Raises one number to the power of another.

Increment and Decrement:
1. Increment (++): Increases a value by 1.
2. Decrement (--): Decreases a value by 1.

Unary Negation and Plus:
1. Unary Negation (-): Converts a number to its negative.
2. Unary Plus (+): Converts a value to a number (if it isn't already).

Order of Operations (Precedence):
1. Follows PEMDAS (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction) to solve any arithmetic.

Key Points:
1. These operators work with numbers, but strings used with + result in concatenation.
2. NaN (Not-a-Number) is returned for invalid arithmetic.

Thanks for watching

27/01/2025

A variable in JavaScript is used to store data that can be referenced and manipulated later. Here's a quick overview:

Declaring Variables
There are three main keywords for declaring variables:

1. var

i. Function-scoped.
ii. Can be re-declared and updated.
iii. Hoisted to the top of the scope but initialized as undefined.
iv. Generally avoided in modern JavaScript.

2. let

i. Block-scoped.
ii. Can be updated but not re-declared in the same scope.
iii. Not initialized until the line where it’s defined.

3. const

i. Block-scoped.
ii. Cannot be updated or re-declared.
iii. Must be initialized at the time of declaration.

Variable Scope:

1. Global Scope: Accessible anywhere in the code.
2. Function Scope: Accessible only within the function.
3. Block Scope: Variables declared with let and const are accessible only within the enclosing block ({}).

Variable Hoisting:

1. Variables declared with var are hoisted to the top of their scope but are initialized as undefined.
2. let and const are hoisted but not initialized (in the temporal dead zone until their declaration).

Variable Types:

Primitive Types (immutable):

i. String
ii. Number
iii. Boolean
iv. Null
v. Undefined
vi. Symbol
vii. BigInt

Reference Types (mutable):

i. Objects
ii. Arrays
iii. Functions

Best Practices:

Use const by default for values that don’t change.
Use let for values that need to be updated.
Avoid using var unless necessary for backward compatibility.

25/12/2024
PROGRAMMING
25/12/2024

PROGRAMMING

Address

9 Ademola Oshinowo Street, Ikosi Ketu, Lagos
Ikeja
100246

Alerts

Be the first to know and let us send you an email when Sasco Jay Tech posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share

Category