JS is weird

JS is weird

When I observe the behavior of JavaScript, I really found it a weird language. It is a compile time as well as scripting language. We use to hear that everything in JS is an object and many other things that make JS a weird language.

Let’s have a look on few examples that shows it’s behavior.

Example 1: typeOf(NaN) is a number.

Example 2: typeOf([]) is an object

Example 3: 9999999999999999 = 10000000000000000

Example 4: 0.1 + 0.3 = 0.4 But 0.1 + 0.2 != 0.3

Example 5: [] + [] = “”

Example?6: [] + {} = “[object, Object]”

Example 7: {} + [] = 0

Example 8: true + true + true = 3

Example 9: true - true = 0

Example 10: true == 1 (it is correct) BUT true === 1 (It is incorrect, false)

Example 11: [] == 0

Example 12: true + false = 1

Example 13: 10,2 = 2

Example 14: !!!true = false

Example 15: 010 - 03 = 5




要查看或添加评论,请登录

Muhammad Arqam ????的更多文章

  • Async-Await

    Async-Await

  • Node Package Manager - JS Bunch

    Node Package Manager - JS Bunch

    This package contains helper functions like sorting function, array manipulation functions, string manipulation…

    2 条评论
  • Node Package Manager - Boilerplate

    Node Package Manager - Boilerplate

    This will create a code boilerplate having all the basic packages installed including all database connections…

    3 条评论
  • Cooperative Caching (COOP Cache)

    Cooperative Caching (COOP Cache)

    Cooperative Caching Strategies in Mobile Ad Hoc Networks Using Remote Client Memory to Improve System Performance…

    8 条评论

社区洞察

其他会员也浏览了