How to update node on mac

I was reading some documentation and i got to know that i need to upgrade my node version. you can check your current node js version by typing this.

Here is the quick way to update node JS version.  First of all just update your Homebrew package manager.

After Homebrew got updated. Now you can update your node js version.

After it updated. Try checking your updating node version.


Continue Reading

Hash vs chunkhash vs ContentHash

From last some days, i was thinking of writing this blog but got too busy with other things. Tonight i get some time on writing on this topic. This particular blog post i have not published here, This is actually published on You can read full blog post by clicking here.   I also had written webpack 1 to webpack 2 migration blog post which you can read by clicking the link.   It’s too late tonight, almost morning now. I should take some nap now.    

Continue Reading

Migration to webpack-2

Recently i have done webpack migration for our React redux project to Webpack 2. There are lot of syntax changes was there (Which i will explain below) that needs to be made. Also webpack also provides features like Tree shaking, Caching, dynamic imports etc which leads to change in compilation time and bundle sizes. Let me give little overview of what all major syntax changes for migration and than we will discuss various feature to improve webpack bundling process. 1. Module.loaders changed to module.rules: In webpack 1, modules.loaders got changed to module.rules, loaders names array is changed to use.         …

Continue Reading

center text in SVG shapes

Whenever you place text inside any SVG shape (rectangle, ellipse, circle etc), you would like to center text in SVG shape. In HTML placing a text relative to parent can be easily done using “text-align: center” property, similarly you can place text center of SVG shape with help of “text-anchor: middle”.  For SVG, it is not that straight forward but i will explain below, how you can achieve it. Let’s first of all create an svg tag as follow:

Now lets add a <g> tag inside svg to group multiple tag inside.

Now let’s add a circle and text tag inside <g> tag. …

Continue Reading

New ES6 Features

ECMAScript 6, also known as ECMAScript 2015, is the latest version of the ECMAScript standard. Implementation of these features in major JavaScript engines is underway now. See the ES6 standard for full specification of the ECMAScript 6 language.   ES6 includes the following new features: Arrow Function Classes Destructuring Constant and let Arrow Function: Arrow functions are a new ES6 syntax for writing JavaScript Functions. They will save developers time and simplify function scope. ES6 fat arrow functions have a shorter syntax compared to function expressions and lexically bind to this value. Arrow Function Syntax:

JavaScript function can be written in two ways …

Continue Reading

Adding large number in JavaScript

Today i had an Interview with one of the company and interviewer guy (Ritesh) asked me very simple problem that “How will you add two numbers if numbers are very large/Add large number in JavaScript?”. Frankly saying, i never gave a thought about this problem ever. My interviewer didn’t got got impressed but still i thought of solving it. So below id the function that i have coded for it. Problem: Javascript support at most 53 bit of integer only. If number goes beyond it, Javascript loose precision.  Small number can be added simply as follow:

But if you try …

Continue Reading

How to install Grunt on Mac OSX

Grunt is a JavaScript task runner, a tool used to automatically perform frequently used tasks like minify CSS, SASS compilation and watching JS files for changes and much more. You can install Grunt on Mac OSX using npm (node packaging manager). Following are the most common tasks performed using grunt:   Uglify Javascript code. Concat multiple file. Watch files for changes Code validation with jsHint etc. Copy files from one location to another. Before installing Grunt, update your npm package (This might need sudo based on your system permission ).


If you are using sudo option, you are asked …

Continue Reading

Javascript : Event binding on Dynamically created element

Whenever we bind events to DOM element, events got attached with all elements which are there in DOM but same events will not get attached to any element which is added dynamically. in order to understand event binding, let’s consider a below DOM structure.

Let’s apply some Styling to above HTML block.

Finally, let’s attach a addEventListener to element with class list-item.

Now if i click on final link, it will translate 30px in Y-axis. You can test the same in Codepen here. Now let’s add a dynamic DIV element with class list item and wrap it inside element with class …

Continue Reading

Angular 2 communication using Services

In this article we will discuss about communication using Services in Angular 2. This is very useful when you have more than one components which need to access and manipulate single source of data. This method is usually used in the following scenario:   Service making API hit to server and share data across all the component inside the web app. Service that pull and push data across multiple component because of it’s singleton property (Single source of truth).   Above are just the very common use cases of this methods. There are other lot of situations where you will be …

Continue Reading