Interesting facts about JavaScript!

Overview:

We use JavaScript unintentionally for a lot of things without even realising it, which is why this presentation is named as "Interesting facts About JavaScript"! 

The most widely used programming language nowadays is JavaScript, as we all know. The language of JavaScript is quite odd. One factor that confuses developers is that it has a syntax that is similar to those of C, C++, and Java yet differs semantically. Its prototype inheritance, which is also strange to note and is possible with the help of an es6 class, is another strange item to remark. Let's talk about some intriguing language-related information.

  • A semicolon is commonly used to conclude a statement in computer languages. Although JavaScript already accomplishes this, statements can also start with a semicolon.

The above bit of code will display 2 in the console without raising an error!

  • You can combine a number with a string in JavaScript. A string without any errors will be the outcome.

In the console, the code snippet will show "59"!

  • When used in JavaScript, comparison operators frequently behave strangely. Observe a few instances.

  • A useful feature of JavaScript is called Immediately Invoked Function Expression, which enables a function to be called automatically after it has been defined.

Here, the first function, which is an IIFE, operates without issue, while the second function produces a syntax error.

  • Two functions in JavaScript can be distinguished from one another by the placement of the parenthesis.

  • Undefined is not a reserved word in JavaScript despite having a specific meaning. Although the following code snippet appears strange, this is the only way to tell if a variable is undefined.

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

  • Delete A Value from Array

Never fall victim to the delete keyword trap. The value of the array will be deleted, but the value will still be there. The value will be deleted if the keyword delete is used, but the array will not actually be re-indexed. It will merely leave the slot vacant. The slot at index 1 in the aforementioned example will be empty, which is why the log entry for that slot reads "undefined." Therefore, even deleting all of the values from an array with the delete keyword will not alter the array's length. Use array.splice(1,1) instead to remove the value from the first to the first number of values.​​​​​​​

  • Why type of null Is Object?​​​​​​​

Nothing here should surprise anyone. It is a JavaScript BUG that is 20 years old. Yes, that is an issue that was impossible to remedy because a significant amount of online code relies on the typeof null === "object" phrase. If not, we anticipate the browser to return "null" as the string value when typeof null is used. Use the following methods to see if a variable has a null value type. The only value that is false yet still an object is Null, which is false

  • "function" Type Value

Functions are merely objects in JavaScript that can have static properties applied to them. However, a certain type known as "function" has been given to them.
Functions are a special type of object that can be called in the JavaScript environment.

Follow Us On

Registered Office

CHG IT CONSULTANCY PVT LTD

STPI Technology Incubation Centre,
2nd Floor, No.5, Rajiv Gandhi Salai,
Taramani, Chennai – 600113,
Tamil Nadu, INDIA

Parent Office

CIC Corporation

2-16-4 Dogenzaka, Shibuya-ku,
Nomura Real Estate,
Shibuya Dogenzaka Building,
Tokyo 150-0043, JAPAN

  +81 03-3496-1571
AboutUs

CHG IT Consultancy Pvt. Ltd. is a subsidiary of CIC Holdings Co. Ltd. Japan. Our company is focused on IT related solutions to reap the benefits of global popularity of Software Industry.

Registered Office
CHG IT CONSULTANCY PVT LTD

STPI Technology Incubation Centre,
2nd Floor, No.5, Rajiv Gandhi Salai,
Taramani, Chennai – 600113,
Tamil Nadu, INDIA

CIC Corporation

2-16-4 Dogenzaka, Shibuya-ku,
Nomura Real Estate,
Shibuya Dogenzaka Building,
Tokyo 150-0043, JAPAN

+81 03-3496-1571