var vs let vs const

No fluff lets get directly into it ! var vs let vs const Declaration var : Can be re-declared even after declaring it once ! let : Cannot be re-declared ! Only one declaration per block ! const : Same as let ! Mutability var : Mutable. Means will let you change values of variables, let : Mutable. Same as var will let you change values of variables. const : Immutable. Won’t let you change values of variables declared using const ! Scopes var: Function Scoped ! function scopeOfVar(){ var x = 8; console.log(x); } scopeOfVar(); console.log(x); //ReferenceError: x is not defined x is defined inside the function, hoisted to the top of the scope (the function in this case) and is not accessible outside of the function. ...

July 12, 2025

Hoisting in Javascript

Hoisting in JavaScript means that any declaration made, JavaScript will move them to the top of their scope before the code runs. 📦 Two types of Hoisting in JavaScript Variable Hoisting : Lets see using examples: console.log(x); //undefined var x = 8; console.log(x); //prints 8 Instead of throwing an error it runs as x is hoisted to the top of the scope therefore its not initialized before the code runs but its declared therefore x is accessible. x is initialized when the line var x = 8 is executed. ...

July 12, 2025

JavaScript Pitfalls

We will see some other quirks and pitfalls here [object Object] We can get the [object Object] if we try to console log a object while trying to concat a string with it. const obj = { val: 32 }; console.log(obj); //prints { val: 32 } console.log(obj + 'A'); //prints [object Object]A Internally JS tries to convert obj into a string by doing obj.toString() resulting in [object Object] ! Now what exactly does it mean ? The first is object (with a small o), this shows the type tag. JavaScript by default tags every datatype as objectif its not a primitive type like number or string. ...

July 12, 2025

Javascript Functions

YEP ! Good ‘ol Functions, very familiar, exists in all programming languages (or does it ?). Now JS does not have one single way of writing functions, it has a whole arsenal of them, lets see each of them one by one. The standard way: function greet(name){ console.log(`Hello, ${ name }`); } greet("Nexus"); //prints "Hello, Nexus" The very basic and old school way of writing functions, totally understandable and good to work with. ...

July 12, 2025

Array Functions

We will see the 3 to 5 frequently used array functions in JavaScript. Now why did I list these in quirks ? I personally say that JavaScript is very quirky and I don’t use this functions often as I don’t like to remember stuff and I never understood how exactly some of them works. On a standard POV this is necessary but I will still say these are quirky ways of writing a loop ! ...

July 11, 2025

JavaScript Quirks

Now Decided to make a log on JavaScript after messing up a Job selection assessment. JavaScript in itself is the most weird and “bad” language I’ve ever coded in, Its loosely typed and has many funky quirks that I absolutely don’t like or use often in my code. But these funky quirks or writing styles are needed for stuff like interviews or codebases that implement these methods of writing. For the context of this Log or any other log tagged/linked to it, I will mention these as “QUIRKS” ! ...

July 11, 2025