JavaScript Technology
jsmeme

JS Quirks – Part-1

Fun with Javascript
JS is a phunny language

Some of us will relate this sentence to the Amitabh Bachchan starrer Namak Haram, but one cannot deny the impact JavaScript has on the evolution of websites, who would like to go back to the 90’s blinky pages that took forever to load and could do no more than navigate from one page to other. 

JS evolved and thankfully became powerful enough to be called the language of the internet, from its initial days of Netscape navigator it is now ubiquitous, so much so we tend to take its presence for granted. 

JS currently finds its usage not only in Webpages but almost all areas of programming and application development, Node, AI/ML, Blockchain are the notable modern tech where JS is not left behind and works hand in hand with them. 

This blog is about some of the fundamentals of JS which if one is cognizant about will reduce the errors and definitely hours of headache of locating the bug. 

This is TIOBE index showing how JS evolved over the years  

Programming Language20232018201320082003199819931988
Python1487132520
C22122111
Java3121117
C++43443226
C#555810
Visual Basic615
JavaScript77119822
SQL82517
Assembly language912
PHP108656
Objective-C181834551
Ada2730171815762
Lisp2931121614643
Pascal19814315199912314
(Visual) Basic735395

Do you know some infinities are greater than other infinities? 

To understand this incredible concept, watch this video https://youtu.be/OxGsU8oIWjY  

function run() { 
    console.log (Math.min() > Math.max()); //--> true 
    console.log (Math.min() < Math.max()); //--> false 
} 
 
run(); 

Surprise? Well, the first thing to understand is Math.max() is not same as Number.MAX_VALUE,  Math.min() and Math.max() can be used to find the lowest or highest value in a list of arguments but if no arguments are provided than Math.min() = Infinity and Math.max() = -Infinity 

function run() { 
    console.log(Math.min()); //-> Infinity 
    console.log(Math.max()); //-> -Infinity 
} 
 
run(); 

Let’s guess what happens when NaN is provided as an argument 

function run() { 
    console.log(Math.min(0, NaN)); //-> NaN 
    console.log(Math.max(0, NaN)); //-> -NaN 
} 
 
run(); 

Image source https://www.freecodecamp.org/news/explaining-the-best-javascript-meme-i-have-ever-seen/

Until next time, that’s all Folks!!

Abizer Saify

Author

Abizer Saify

Abizer is a catalyst of digital and tech transformation and a leader who is passionate about people, processes and technology. He comes with a global outlook after having worked in US, Europe and ASPAC regions in BFSI, Media and manufacturing industries. Abizer is constantly learning, adapting and evolving himself with the latest in technology and business world. He is adept at digital, design thinking, UX, core applications and ERP. He can be reached at [email protected]