Skip to main content

Posts

Javascript 102 : Understanding 'this' keyword

The keyword "this" is frequently misunderstood when coding with Javascript. It is because its behavior depends on the execution context. Now what is "execution context"? It is mainly of three types. Global Execution Cotnext (GEC), Functional Execution Cotnext (FEC) and Eval. In GEC, it is the global environment which Javascript  (JS) is running. If you are running the script in a browser and you use the "this" keyword, it will refer to the "Window" object. But if you are using NodeJS and running the script outside a browser the "this" keyword would refer to the "Process". In FEC the "this" keyword would refer to the execution context created by the code inside the function. EVAL is hen you use the "this" keyword inside an "eval" function. If this does not make sense, don't worry because we are going to understand with an example which is always the best way. Make the following HT...

Javascript 101 : var, let and const

Let's understand variable types "var", "let" and "const" in Javascript.  Basically there are 3 ways to create variables in java script using 3 keywords as follows.  There differences are as follows,  01. The "variable01" which was created with "var" keyword, does not have a blocked scope. which means, you have to be careful when using it. A variable declared inside an "if" block can be changed outside the block.  02. The "variable02" which was created with "let" keyword, has blocked scope. A variable with "let" keyword declared inside an "if" block is not available outside the block. 03. The "variable03" which was created with "const" keyword, is a constant. Which means you have to initialize it once you declare it, and that value cannot be modified later in the programs. There will be an error if you try to do so.  Now lets explore ...

NodeJs 101 : A Quick Look

Unless you have been living in a cave in the past several years, you must have heard something about "NodeJS" or just "Node" by now. So what is it and what's all the noise is about? In short, it is JavaScript running outside the web browser. Wait,.... what? ....... JavaScript has always been running in a web browser, hasn't it? Well, not anymore since 2009. Now it runs outside the web browser, but where? .... On the Google's V8 engine. (Sometimes it is called the Chrome V8 engine). V8 engine can convert your JavaScript code to machine code and run it out side the browser. Now don't ask "So What? .....". Because this means, if you are developing on a web application, now you can add stunning behaviors in the client side, as well as complete all the server side scripting with JavaScript. This is the reason for the aforementioned noise, and the reason for JavaScript to become one of the most highest demanding skill in the past severa...