“Perbedaan antara == dan === Operator.” Kode Jawaban

Perbedaan antara == dan === Operator.

/*
== in JavaScript is used for comparing two variables.
=== is used for comparing two variables, 
but this operator also checks datatype and compares two values
*/

0 == false   // true
0 === false  // false, because they are of a different type
1 == "1"     // true, automatic type conversion for value only
1 === "1"    // false, because they are of a different type
null == undefined // true
null === undefined // false
'0' == false // true
'0' === false // false
Tiny Coders

Apa perbedaan antara == dan === operator

0 == false   // true
0 === false  // false
1 == "1"     // true
1 === "1"    // false
null == undefined // true
null === undefined // false
'0' == false // true
'0' === false // false
[]==[] or []===[] //false, refer different objects in memory
{}=={} or {}==={} //false, refer different objects in memory
Gleaming Guanaco

Jawaban yang mirip dengan “Perbedaan antara == dan === Operator.”

Pertanyaan yang mirip dengan “Perbedaan antara == dan === Operator.”

Lebih banyak jawaban terkait untuk “Perbedaan antara == dan === Operator.” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya