Few Cool Things About Javascript
1 min readDec 1, 2024
In this article I am listing few lesser known facts about Javascript.
- NaN ( called “Not a number”) is a number itself.
- NaN is not equal to anything not even NaN itself. (console.log(NaN == NaN) //Output :: false).
- JavaScript allows variables to hold different types of data at different times without explicit type declarations.
- Functions in JavaScript are first-class citizens, meaning they can be assigned to variables, passed as arguments, and returned from other functions.
- JavaScript supports closures, which occur when a function “remembers” its lexical scope even after being executed.
- Earlier Javascript came up with only one way to declare variable which was “var”. Later they came up with “let” and “const”.
- Javascript was called as “Mocha” earlier and was developed in just 20 days.
- Mocha was renamed as Livescript and then Javascript.
- The typeof operator returns “object” for null. (console.log(typeof null); //Output :: object).
- You can use double negation to convert any value to a boolean.
- The void operator evaluates an expression and returns undefined (console.log(void 0); //Output :: undefined).
- The comma operator evaluates multiple expressions and returns the last one (const result = (1, 2, 3); console.log(result); //Output :: 3).