Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is === in javascript? [duplicate]

Tags:

javascript

People also ask

What is a === in JavaScript?

The strict equality operator ( === ) checks whether its two operands are equal, returning a Boolean result. Unlike the equality operator, the strict equality operator always considers operands of different types to be different.

What does == === mean?

The === operator means "is exactly equal to," matching by both value and data type. The == operator means "is equal to," matching by value only.

What is == vs === in JavaScript?

== in JavaScript is used for comparing two variables, but it ignores the datatype of variable. === is used for comparing two variables, but this operator also checks datatype and compares two values. Checks the equality of two operands without considering their type. Compares equality of two operands with their types.

What is triple === in JavaScript?

JavaScript provides three different value-comparison operations: === — strict equality (triple equals) == — loose equality (double equals)


=== is the strict equal operator. It only returns a Boolean True if both the operands are equal and of the same type. If a is 2, and b is 4,

a === 2 (True)
b === 4 (True)
a === '2' (False)

vs True for all of the following,

a == 2 
a == "2"
2 == '2' 

=== is 'strict equal operator'. It returns true if both the operands are equal AND are of same type.

a = 2
b = '2'
a == b //returns True
a === b //returns False

Take a look at this tutorial.