Creating a Knockout TExt
Learning new things everyday is part of what makes being a rational human being great. And as developers, it is part of our job to learn new things continuously, whether or not these things are from positive learning experiences. In this tutorial, I will point out a few important JavaScript best practices so you don’t have to learn it the hard way. Get ready to level to your code! 1. Avoid polluting the global scope Declaring variables is a lot of fun. Sometimes, you may declare global variables even if you don’t want to. In today’s browsers, the global variables are stored in the window object. So, since there’s a lot of stuff going on there, you may override default values. Let’s suppose you have an HTML file which contains a <script> tag containing (or which loads a JavaScript file containing): var foo = 42 ; console . log ( foo ) ; This will obviously output 42 in the console. But since the code is not executed in a function, the context will be the glob