JavaScript has several built-in global functions that can be used in any JavaScript code, regardless of where the code is located.
Basics
Commonly Used JavaScript Statements
In this article, we will discuss some of the most commonly used JavaScript statements and provide code examples for each.
Comparison and Logic Operators in JavaScript
JavaScript has several comparison and logic operators that are used to compare values or perform logical operations.
Bitwise Operators in JavaScript
JavaScript provides several bitwise operators that allow you to manipulate the individual bits within a value. These operators include: Here’s a brief explanation of each operator and an example of how to use it: Bitwise AND (&) The bitwise AND operator compares each bit of the first operand to the corresponding bit of the second […]
Assignment Operators in JavaScript
JavaScript has several assignment operators that can be used to assign values to variables. These operators are as follows: The “=” operator: This is the most basic assignment operator and is used to assign a value to a variable. For example: The “+=” operator: This operator is used to add the value on the right […]
The JavaScript function Math.pow()
The Math.pow() function in JavaScript is used to raise a number (called the base) to a certain power (called the exponent). The syntax for using this function is Math.pow(base, exponent). For example, to raise 2 to the power of 3, you would use the following code: In this example, 2 is the base and 3 […]
The JavaScript function Math.floor()
The JavaScript function Math.floor() is used to round a number down to the nearest integer. This function takes a single argument, which is the number that you want to round down. For example, if you wanted to round the number 4.7 down to the nearest integer, you would use the following code: As you can […]
The JavaScript function Math.abs()
The JavaScript function Math.abs() is a built-in function that returns the absolute value of a number. The absolute value of a number is its distance from zero, regardless of whether the number is positive or negative. Here is an example of how to use the Math.abs() function: In the above example, num1 is assigned the […]
Arithmetic Operators in JavaScript
JavaScript has several arithmetic operators that are used to perform mathematical operations on numbers. These operators include: Addition (+): This operator is used to add two or more numbers together. Subtraction (-): This operator is used to subtract one number from another. Multiplication (*): This operator is used to multiply two or more numbers together. […]
Default Function Parameters
Provide a default value to a function parameter.