Javascript Journey

Hey there,

I have been thinking about organising things i learned and still learning at a single place like this.
So instead of going to google and then stack overflow i can directly come right here.
Wow . Brilliant idea . Nobody would have never thought about this. Classic.
I know you may think like that. But wait. There is more. I bet you can find atleast one new thing from here.
Lets start with some very basic one.
What is a closure?
So baby pull me closure in the back seat of your ... nop not that.
A closure is basically an inner function that has access to the outer or enclosing function's variables.

So the canIGoToMars returns the inner function firstThingFirst.
canIGoToMars function has a variable in its local scope called greeting.
firstThingFirst function has access to the greeting variable . It console logs the greeting variable plus the name variable we pass into the canIGoToMars function.
An example of closure.
HTML
CSS
Javascript
{% codepen https://codepen.io/sandeepbalachandran/pen/NWWWOvd default-tab=js,result %}
###References MDN Web Docs [Dude Explaining Closure] (https://www.youtube.com/watch?v=71AtaJpJHw0)
Lets wrap up with a real complex javascript scenario only god can answer.
How to console a certain word without using its entire letters
Say here its 'banana'. We can use most likely
console.log(('b' + 'a' + + 'a' + 'a').toLowerCase());
Developers are still researching on this.
If we can go through their updates it would be
+'a' resolves to NaN ("Not a Number") because it coerces a string to a number, while the character a cannot be parsed as a number.
Thats it for now.

Sandeep B
Frontend engineer writing about Angular, JavaScript, and the occasional deep dive into whatever's currently breaking my build.