JSFiddle - React, Tailwind, and code Playground

by Jon Kittell

HTML

<p id="message" onclick="write"></p>

JavaScript

function write(message) {
    document.getElementById('message').innerHTML += message + '<br/>';
}

// objects are only equal to themself
// primatives are equal if the values match ("cat" === "cat")

// two sets of equality operators (== and ===)
    // type coercion
    // stick with "===" and "!=" because they don't use type coercion

// objects are equal to themself
var joe = { name: "Joeseph" };
write("joe equals joe: " + (joe === joe));

// objects are not equal to other objects with the same values
var joe2 = { name: "Joeseph" };
write("joe equals joe2: " + (joe === joe2) + "<br/>");

// primitive types are equal if their values match
write("apple === apple: " + ("apple" === "apple"));
write("apple === cat: " + ("apple" === "cat"));
write("16 === 16: " + (16 === 16));

// inequality
write("1 !== 2: " + (1 !== 2));
write("1 != 2: " + (1 != 2));

// the == operator
write('1 == "1": ' + (1 == "1"));
write('"" == 0: ' + ("" == 0));