Open In App

Most 5 Weird Behavior of JavaScript

In this article, we will be talking about the weird facts of JavaScript. JavaScript is famous for its wide acceptance and also famous for its weirdness. The examples that are given below can blow the mind of the developers who came from C++, Java, C#, and other languages. JavaScript is an object-oriented programming language but the class concept was introduced in ES6. You can write HTML comments in JavaScript, min is greater than max and many more oddities of JavaScript will be covered here.

1. HTML comments in JavaScript: You can write HTML comments in JavaScript for their validity. You can use HTML tag <!– –>  in your JavaScript code without any error because these comments are treated as // of the JavaScript comment. These comments are used in the <script> tag for the old browser that does not understand JavaScript.



 



2. Min is greater than Max: The Math.min() is greater than Math.max()

3. In JavaScript true + true + true == 3 You can see true + true + true is equal to 3.

4. NaN is not NaN: NaN is not equal to NaN even when we use strict equality operator (===).

5. The true is false: When we compare the string true and string false after applying two ! operator, then we get true.


Article Tags :