10 Things You Didn’t Know About JavaScript (most likely)

Learning JavaScript is like swimming on the ocean. One may be in the development field with JavaScript for many years but still there is something he may not know! Today I will share some of them that you may not know.

  1. JavaScript was originally going to be called LiveScript, but it was renamed in an ill-fated marketing decision that attempted to capitalize on the popularity of Java language — despite the two having very little in common. This has been a source of confusion ever since.

2. NaN is not equal to NaN !

3. You can define Object keys from variable directly:

4. The length property of Array is not always the number of items the array contains.

For instance:

Remember, the length of an array is one more than the highest index.

5. If you use expressions in switch statements it won’t convert implicitly. It will act like === operator.

6. Empty string(“”) is treated as falsy value but empty array([]) and empty object({}) are treated as truthy value.

Consider this:

If you want to use them as truthy value then use array.length or object.property

7. String started with “0x” are treated as hexadecimal number.

8. You can write any character of any language using the escape sequence. Write "\u{XXXXXX}" where XXXX is 1–6 hex digits in the range 010FFFF . e.g. “\u{0985} is “অ”. See the Unicode chart for all the character values.

9. Random function of Math object returns floating point between 0 to 1. But use can get any random number between any two integers using this formula:

Though random is not so random!

10. You can create custom properties for Arrays.

That’s it for today. Keep exploring JavaScript.

Peace!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store