Some Interesting Facts in JavaScript

Some Interesting Facts in JavaScript. JavaScript is a popular scripting language with some weird facts.

JavaScript, which was created to “make web pages alive”, is one of the feature-rich language. However, this scripting language has got many peculiarities which is distinct from other programming language. So, here we are going to view some interesting facts in JavaScript. We will see some history and some programming ways which are different from others.

Let’s see some facts:

JavaScript had another name initially: LiveScript. Also, ECMAScript is the standard of the JavaScript.

JavaScript is completely different from the language Java. Java was very popular at that time, hence a “younger brother” of Java was the position it was considered to take. Given these points, the interesting fact is that, it has no relation with Java at all.

JavaScript was initially created for client side scripting, however we can use it as server side scripting language too.

There are many languages which are over “JavaScript” such as “CoffeeScript”, “TypeScript”, “Flow”, “Dart”, etc.

You cannot use src and the codes in a single <script> tags like below:

<script src="script.js">

We can omit semicolon at the end when there exists a line break, however, in some cases it may not be true. For example in the following code, you will get an error:

alert("This is an alert")
["Hello", "World"].forEach(alert)

Likewise, we cannot nest a comment inside another comment. However, this is not only for JavaScript.

use strict only works at the top of the code, or the function body. This code makes the script work the modern way. We cannot revert to old code if we use it once.

JavaScript doesn’t kill the execution if it encounters Infinity, or Not a Number after the operation.

null is an object, whereas undefined is undefined.

typeof(x) or typeof x? You can use the both.

You can test some mathematical operations:

alert("10"/"2"); // 5
alert(1 + "2"); // 12
alert("1" + 2); // 12
alert("1" + 2 + 3); // 123
alert(1 + 2 + "3"); // 33

Using + before a string tries to convert it into numbers. e.g. +"22" gives us a number 22. Moreover you can try, +true, +"", and see the result.

Similarly, Or || finds the first true value and AND && finds the first false value, otherwise last true value. For instance:

result = false || "Hello" || "";  // "Hello"
result  = true && "Hello" && ""; // ""

Final Words

We looked into some basic facts which are interesting in JavaScript. We will be looking into others in another post.

Furthermore, if you want to look into how to deploy django in heroku, you can follow the post here:

Similarly, you can check this link here if you want to know about data structures: I have got them in examples.

0 0 votes
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments