Member-only story

Few Cool Things About Javascript

Aditya Srivastva
1 min readDec 1, 2024

--

In this article I am listing few lesser known facts about Javascript.

Photo by Safar Safarov on Unsplash
  1. NaN ( called “Not a number”) is a number itself.
  2. NaN is not equal to anything not even NaN itself. (console.log(NaN == NaN) //Output :: false).
  3. JavaScript allows variables to hold different types of data at different times without explicit type declarations.
  4. Functions in JavaScript are first-class citizens, meaning they can be assigned to variables, passed as arguments, and returned from other functions.
  5. JavaScript supports closures, which occur when a function “remembers” its lexical scope even after being executed.
  6. Earlier Javascript came up with only one way to declare variable which was “var”. Later they came up with “let” and “const”.
  7. Javascript was called as “Mocha” earlier and was developed in just 20 days.
  8. Mocha was renamed as Livescript and then Javascript.
  9. The typeof operator returns “object” for null. (console.log(typeof null); //Output :: object).
  10. You can use double negation to convert any value to a boolean.
  11. The void operator evaluates an expression and returns undefined (console.log(void 0); //Output :: undefined).
  12. The comma operator evaluates multiple expressions and returns the last one (const result = (1, 2, 3); console.log(result); //Output :: 3).

--

--

No responses yet