JavaScript Operators And Types
Operators and Types of Operators
Operators :
Operators in a programming language are symbols used to perform operations on the values.
The values are termed as operands.
Operators are categorized as unary, binary and ternary operators based on the number of operands on which they operate in an expression.
Statement formed using operator and operands are called expression. In the above example, 5+10 is an expression.
JavaScript supports the following types of operators:
string :
Arithmetic operator + when used to concatenate two strings results into concatenation.
Arithmetic operator + when used with a string value and a numeric value, it results in a new string value.
Arithmetic :
Arithmetic operators are used to performing arithmetic operations.
Assignment :
Assignment operators are used to assigning values to the variables.
Relational or Comparison :
Relational operators are used to comparing values and the result of the comparison is always either true or false.
Relational operators shown below does implicit data type conversion of one of the operands before comparison.
Relational operators shown below compares both the values and the value types without any implicit type conversion.
Strict equality (===) and Strict inequality (!==) operators consider only values of the same type to be equal.
Hence Strict equality and Strict inequality operators are highly recommended to determine whether 2 given values are equal or not.
We will be using these operators in our further exercises.
Logical :
Logical operators are used for combining one or more expressions and make decisions.
typeof :
typeof is an operator in JavaScript.
JavaScript is a loosely-typed language. The type of data assigned to a variable is decided at runtime. This is also called dynamic data binding.
As programmers, if required we can use this operator typeof to find the data type of a JavaScript variable.
Following are the ways it can be used and the corresponding results that it returns.