# Most 5 Weird Behavior of JavaScript

• Difficulty Level : Basic
• Last Updated : 01 Jun, 2021

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.

• Example:

## Javascript

 ``

Output :

`Hello world`

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

• Example 1:

## Javascript

 ``

Output :

```true
false```
• Example 2: One more thing that is Math.max() returns -Infinity and Math.min() returns Infinity

## Javascript

 ``

Output :

```-Infinity
Infinity```

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

• Example 1: This returns 3 because when we add two booleans (true or false) then they automatically typecast into number. In this example, the true is typecasted into number and when we type cast true to a number then we get 1 and when we type cast false into number then we get 0.

## Javascript

 ``

Output: So true + true + true becomes 1 + 1 + 1, hence we got the result 3.

•

• Example 2:

## Javascript

 ``

Output:

```1
0```
• Example 3: Here are some interesting result related to this example.

## Javascript

 ``

Output:

```2
1
0
2
0
3```

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

• Example:

## Javascript

 ``

Output:

```false
false```

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

• Example 1: When we apply two logical not operator, we get true.

## Javascript

 ``

Output:

```true
true
true```
• Example 2: When we compare true and true, we get true.

## Javascript

 ``

Output:

```true
```

My Personal Notes arrow_drop_up