Member-only story

Interesting JavaScript Results

Sumit kumar Singh
1 min readMar 18, 2023

NaN (Not a Number) is a special value in JavaScript, and even NaN is not equal to itself.

console.log(NaN === NaN); // false

An empty array is considered a truthy value.

console.log(Boolean([])); // true

The typeof null returns “object” in JavaScript, which is a long-standing bug in the language.

console.log(typeof null); // object

Adding a string and a number together results in a string concatenation, rather than a mathematical addition.

console.log("2" + 2); // "22"

The Math.max() function in JavaScript can be used to find the maximum value in an array.

console.log(Math.max.apply(null, [1, 2, 3, 4])); // 4

In JavaScript, functions are objects, and can have properties and methods just like any other object.

function myFunction() {
console.log("Hello, world!");
}

myFunction.myProperty = "This is a property of myFunction.";

console.log(myFunction.myProperty); // "This is a property of myFunction."

--

--

Sumit kumar Singh
Sumit kumar Singh

Written by Sumit kumar Singh

YouTube: https://shorturl.at/8zZ4B Topmate: https://topmate.io/sumit_kr_singh 📚 HTML, Angular, React, and JavaScript 🧑‍💻 Tips & tricks

No responses yet