Keywords
JavaScript keywords are predefined, reserved words that have a special meaning within the language syntax. Because the engine treats these tokens as structural components, you cannot use them as identifiers (names for variables, functions, classes, or loops).

JavaScript Operators
JavaScript operators are symbols or keywords used to perform operations on values and variables. They are the building blocks of JavaScript expressions and can manipulate data in various ways.There are various operators supported by JavaScript:
- Arithmetic Operators
- Assignment Operators
- Comparison Operators
- Logical Operators
- Ternary Operators
- The typeof Operator
- Bitwise Operators
In this section, we will explore the arithmetic operators addition (+) and subtraction (-) in JavaScript.
Arithmetic Operators
Arithmetic operators are mathematical symbols used to perform basic calculations (like addition, subtraction, multiplication, and division) on numbers or variables. They are the fundamental building blocks of both daily math and computer programming.

Example
let x = 3;
let y = 8;
console.log(x + y); // 11
Concatenation of Strings in JavaScript
String concatenation is the process of joining two or more strings into a single string. JavaScript provides simple and flexible ways to combine strings for display, logging, or data manipulation.
- Using the + operator to join strings.
- Combining strings with variables and expressions easily. The most common and straightforward approach combines strings using the plus sign. If you mix strings with numbers, JavaScript automatically converts the numbers into strings.
Example
let i = '10';
let j = 5;
console.log(i + j);//105
Subtraction operator
The subtraction operator is marked by the minus sign − and you can use it to subtract the right operand from the left operand.
let x = 5;
let y = 3;
console.log(x - y); // 2
Type Conversion
Type conversion is the general process of changing a value from one data type to another in JavaScript (such as turning a string into a number).It is split into two categories:
- Implicit Type Conversion (automatically done by JavaScript) and
- Explicit Type Conversion (manually done by you, which is commonly referred to as Type Casting)
Implicit Type Conversion (Type Coercion)
In JavaScript, the implicit type conversion or coercion conversion can be defined as the automatic conversion of the data type of the variables from one type to another type. Implicit type conversion mostly occurs when we are performing the arithmetic or the logical operations.
Examples
String with Number (Concatenation)
When we add a string with the number, the JavaScript automatically converts the number into a string and performs string concatenation.
let res = 5 + "5";
console.log(res);//55
Boolean to Number
When we perform the mathematical operations, then JavaScript automatically converts true to 1 and false to 0.
let res = true + 1;
console.log(res);//2
Equality Comparison (==)
When we use the equality operator in the JavaScript, it compares them after converting the value into the same data type.
let res = (5 == "5");
console.log(res);//true
Automatic Conversion in Logical Operations
In JavaScript, these values are automatically converts undefined, null,
"" (empty string), false, NaN, and 0 to false, and all other values to true.
let res = Boolean("");
let res2 = Boolean("Hello");
console.log(res)//false
console.log(res2)//true
Explicit Type Conversion
In JavaScript, explicit type conversion can be defined as when we manually change the data type of the variable from one to other using some built-in JavaScript functions. JavaScript provides us the built-in functions for performing the explicit conversion.
Examples
Conversion to Boolean
Boolean(0); // false
Boolean(''); // false
Boolean(null); // false
Boolean(undefined); // false
Boolean(NaN); // false
Boolean(-0); // false
Boolean(false); // false
-------------------------------
Boolean(1); // true
Boolean(-10); // true
Boolean('apple'); // true
Boolean([]); // true
Boolean({ a: 'a' }); // true - every non-primitive value is converted to true
Boolean({}); // true - even the empty object
Boolean(Symbol()); // true
Boolean(Symbol('x'));// true
Conversion to Number
Number(0); // 0
Number(''); // 0
Number(null); // 0
Number(NaN); // NaN
Number(undefined); // NaN
Number(true); // 1
Number(false); // 0
Number(Symbol()); // TypeError
Number(' 5 '); // 5
Number(' '); // 0
Number('\n'); // 0
Number('-1/2'); // NaN
Number('105.4'); // 105.4
Conversion to String
String(0); // '0'
String(''); // ''
String(true); // 'true'
String(NaN); // 'NaN'
String(undefined); // 'undefined'
String(null); // 'null'
String(Symbol()); // 'Symbol()'
String(Symbol('x')); // 'Symbol(x)'
String(-105.4); // '-105.4'
String([]); // ''
References
https://www.freecodecamp.org/news/javascript-operators/
https://www.geeksforgeeks.org/javascript/javascript-operators/
https://www.w3schools.com/js/js_reserved.asp
Top comments (0)