The Javascript Keyword var

Why am I blogging this? For such a simple keyword. I made this post to remind me that after so many years of using Javascript, I now know what the purpose of the keyword var really is for. The purpose for using the var keyword on a variable is to make it locally scoped. This means that if you use that inside a function, the variable’s scope is gone once the function is finished processing. I never noticed any difference with using a var or not simply because there never came a point in time that I would be having problems with the values of a variable. Until now. When I had problems with the values on a single variable, I was confused why. I tried to add the var keyword thinking, who knows right? And it worked! That was the time I decided to look up the purpose of the var keyword in Google and found the answer.

I laugh at myself why I discovered this until now after so many years. But hey, better late than never right? At least now I know he he he :D.

Related Posts Plugin for WordPress, Blogger...

1 comment

  1. Hahaha! It’s simply amazing that things like that could somehow change the history of your life. Though I must admit, I really wouldn’t want my eyes to stare that “var” thing for too long, not only can’t I accept that in my universe, but I really don’t have the interest. Tell me something graphical and I’ll fetch it. ^_^

    Good luck on your next discoveries. ^_^

Leave a Reply

Your email address will not be published. Required fields are marked *