Skip to content

JavaScript Data Comparison

المعرفة:: JavaScript
الحالة:: ملاحظة_مؤرشفة
المراجع:: JavaScript Essential Training


Comparison

// Unlike the strict equality operator, it attempts to convert and compare operands that are of different types.  
console.log(1 == 1);  
// expected output: true  

console.log("hello" == "hello");  
// expected output: true  

console.log("1" == 1);  
// expected output: true  

console.log(0 == false);  
// expected output: true  

// Unlike the equality operator, the strict equality operator always considers operands of different types to be different.  
console.log(1 === 1);  
// expected output: true  

console.log("hello" === "hello");  
// expected output: true  

console.log("1" === 1);  
// expected output: false  

console.log(0 === false);  
// expected output: false  

Last update : August 14, 2023
Created : August 23, 2022

Comments

Comments