Js The Weird Parts [High-Quality • 2024]

const obj = { showThis: showThis }; obj.showThis(); // obj

It gets weirder:

function showThis() { console.log(this); } showThis(); // window (or undefined in strict mode) js the weird parts

console.log(isNaN(NaN)); // true // But wait... console.log(isNaN("hello")); // true (because "hello" can't be a number) That’s why ES6 gave us Number.isNaN() which actually behaves. In many languages, if you forget to declare a variable, you get an error. In JavaScript (non-strict mode), you get a present : const obj = { showThis: showThis }; obj