Blog Archives

HOISTING in JavaScript

Tweet HOISTING in JavaScript :All JavaScript variables are hoist at the top of the scope (function) in which they are defined. To understand it consider the code snippet shows below, var foo = "foo"; console.log(foo); Above code will print foo

Posted in Javascript

Callbacks ?

Tweet What is Callbacks : You pass a function reference as a parameter to another function so that it can be executed at a later time function f1(a){ } function f2(b){ var a=10; b(a); } f2 (f1); Here i am

Posted in Javascript, Node.Js Tagged with: ,

Constructor Function 2 ?

Tweet How Does That Work? Here’s what happens when a function is called with the “new” keyword :- A call to “new Foo()” creates a new object instance, said to be of type “Foo”.The object instance is assigned a prototype

Posted in Javascript Tagged with:

Constructor Function ?

Tweet A Constructor Function : Consider the following function and call to the function: function Foo(){ this.bar = "baz"; console.log(this); } var f = new Foo(); console.log(f.bar); In this example, the “Foo” function is being used as a constructor function

Posted in Javascript Tagged with:

Method Calls on Objects 3 ?

Tweet When A Method Becomes A Function : The fastest way is to assume that a function is assigned “this” based on the object on which it is defined.In fact, the value of “this” can change dramatically, not based on

Posted in Javascript

Method Calls on Objects 2 ?

Tweet Go back to the simple rule which was : "Method calls assign "this" to the object from which they are called" .Let’s dissect this and assign each part of the rule to the above code. 1) Method call: A

Posted in Javascript

Method Calls on Objects ?

Tweet Method Calls On objects: A basic simple rule is “Method Calls Assign “this” To The Object From Which They Are Called“. JavaScript can be used in an object-oriented manner. In fact, almost everything in JavaScript is an object, whether

Posted in Javascript

Strict Mode In A Browser

Tweet Modern browsers have a “strict” mode that you can enable with a very simple command: “use strict”.This is done for backward compatibility reasons with older browsers. When “use strict” is set inside of a function, that function is said

Posted in Javascript, Node.Js Tagged with: ,

Simple Function Invocation ?

Tweet Simple Function Invocation The single most basic way to invoke a function in JavaScript is to supply the () parenthesis to a function that is just floating around, waiting to be called. function doStuff(){ console.log("I'm doing blah blah!"); console.log(this);

Posted in Javascript Tagged with:

this javascript ?

Tweet This is always a very confusing to understand “this”.There are only 5 rules you need to understand, to master the value of “this” in any function and any object in JavaScript. These rules are all based on how you

Posted in Javascript Tagged with: