Posts

Coercion in JavaScript

  What is Coercion in JavaScript? In JavaScript, the process of converting the type of a variable into another is called Coercion. This means a variable of string type when changed to a number type due to some process is called coercion of the variable. let a="34"; //defining a as string type let b=5; //defining b as a number type let sum=a+b; console.log(sum); // 345 ?? typeof(sum); //The result would be "string" In the above code snippet, since the variable a is defined as a string type, it will be considered as a string. Hence JavaScript has coerced the 5 from a number into a string and then concatenated the two values together, resulting in a string of 345 . Now, let’s take another case. let a=34; //defining a as string type let b=5; //defining b as a number type let sum=a+b; console.log(sum); // 39 typeof(sum); //The result would be "number" The above code makes it clear that since both the variables were declared as a Number, the resulting s...

HISTORY MYSTERY: ORIGIN OF THE TERM DEBUGGING

Image
Ever wondered where the term debugging came from?  Well, it has an interesting history.    On September 9, 1947,Grace Murray Hopper records the first computer bug in the Harvard Mark II computer's log book. In this case, it literally was a bug. Operators including William Burke found a ... Moth, between the relays on the Harvard Mark II Computer they were working on.  In those days, computers were large enough to fill rooms, and the warmth of its internal components attracted moths, flies and bugs ... Although the term 'bug in a computer' has been used before, it became widely popular after Grace Hopper wrote, "First actual case of bug being found" in the log book.                            Source Since then, the term Debugging the bug became really popular.    This is how computers during late 1940s looke...