Recap of 2018

Hi Reader,

THANK YOU, for being with me in 2018. It was another good year due to your Support, Trust, and Love. Besides, you, I would like to thank my employer Infragistics and my boss Jason Beres that they gave me opportunities to contribute to developer community.

If you are an Angular developer, you may want to check fastest native Angular component library Ignite UI for Angular.

In 2018, I wrote articles, delivered talks in small meetups or big conferences, organized conference of 400 developers.

In 2018, I mainly focused on JavaScript and Angular. I was able to do the following:

Organizing ng-India was a kind of learning yet motivating experience. Since this was first ever-Angular specific conference in India, I had my doubts. However, everything went as planned. We sold all 300 tickets in less than one month and was joined by speakers from all across India. From printing goodies, printing T-Shirts, doing social media, to receiving speakers at AirPort, to delivering two talks, I had fun in almost everything in ng-India.

See Photos of ng-India here

I must thank all sponsors, volunteers, and speakers of ng-India. Without them, it was never possible. A special thanks to Shivprasad Koirala  and   Questpond for their trust in ng-India. Yes, finally yet importantly a big thank to vibrant Angular community for all motivation.

I delivered 11 talks in 2018. To deliver these talks, I travelled to six Indian cities and a country Nepal. Out of 11 talks, five talks were in big conferences such as ng-India, ng-Nepal, Pune Developer Conference and five talks were kind of workshops hosted by me in various cities. I also did one webinar for ng-Frankfurt.

I wrote 28 articles mainly on Angular and JavaScript and wrote an Angular Essential E-Book. I hope, I was useful to you in 2018.

Also in 2018, I got Microsoft MVP Award, which was ninth MVP Award for me since 2010. I have been getting it every year since 2010. I also had opportunity to attend MVP Summit in Seattle.

If you are reading my blog since 2010 and wondering, how I look on 31 December 2018, below photo is taken today


With all happiness, I wish you Happy New Year 2019. Keep learning, writing, teaching, and implementing. I am very excited for 2019.  Happy Coding.

Thanks with Regards

Dhananjay Kumar

Simplifying Object.assign method in JavaScript

Read full article on the Infragistics blog

“In JavaScript, Object’s assign method copies source object’s own enumerable properties to a target object, and returns that target object “

There are two important keywords in the above sentence:

  1. Enumerable
  2. Own

Before we go ahead and understand purpose of Object.assign, it is essential that we really understand these two words, enumerable properties and own properties.  Let us see them one by one:

A JavaScript object could have either enumerable or non-enumerable properties. However, by default when you create property on an object, it is enumerable.  Enumerable  means you can enumerate through those properties. Let us understand it through code.



There are two properties in babycat object. By default both are enumerable, hence as the output of loop, you will get both age and name printed.

Now let us change default enumerable behavior of age property using Object.defineProperty method.


We have changed enumerable of age property to false, so as output, you will get only color printed. Hence, age is no longer an enumerable property of babycat object.

Another keyword in above sentence is own properties. To understand it, you need to understand object prototype chain. All JavaScript objects are part of a prototype chain, hence can access properties of its prototype’s also.  So, own properties are those properties, which are particular to the object and not from the prototype chain.  Let us understand own properties through code examples,

In above code snippet, there are two objects cat and babycat. In addition, [[Prototype]] property of babycat object is set to cat object. When you print properties of the babycat object using loop, you will find as output age, color, name printed as shown in below image:

What is happening here? Well, JavaScript prints all properties from the prototype chain. However, only age and color are, own properties of babycat object.

As of now, you should have understood own properties and enumerable properties in context of a JavaScript object.   So let us revisit first statement of this post,

“In JavaScript, Object’s assign method copies source object’s own enumerable properties to a target object, and returns that target object “

You should able to infer what exactly above sentence implies.  Consider code below :






Using Object.assign() method , we are copying cat object own enumerable properties to babycat object. Here, cat object is source and babycat object is target. You will get output printed as below:

The Object.assign() method uses [[Get]] on the source object and [[set]] on the target object and invokes setter and getter to perform the task. Essentially, it assigns properties values from source to target object. It does not create new property in the target object.

As of now you know purpose of the Object.assign() method. Let us examine some variations while copying properties from source object to a target object.

Same Properties in both target and source object

If target object has same properties as of source object, then Object.assign() method will  override target object properties.  To understand it consider code listing below:





There is age property in both target object and source object.  While copying properties in target object the Object.assign() method will override target object age property, hence you will get output as shown in the below image :

Read full article on the Infragistics blog

Video – JavaScript object instances does not copy definition from the class

I recently wrote a blog post about Two Problems of a JavaScript Class. In my opinion one gotchas in a JavaScript class is , object instances does not copy definition from the class.

Watch this video to understand it through codes.  f you like the video , do not forget to subscribe to our YouTube Channel for notification about future video tutorials.


Video – Step by Step Component Communications in Angular

In Angular, components communicate to each other to share data such as object, string, number, array or html.

Parent and Child Components can communicate to each other in following ways

Parent and Child Components can communicate to each other in following ways

  • @Input()
  • @Output()
  • Temp Ref Variable
  • ViewChild and ContentChild


You can learn about these concepts in step by step video below.  If you like the video , do not forget to subscribe to our YouTube Channel for notification about future video tutorials.




You can read articles related to above video here :

Communication Between Components Using @Input() in Angular

Understanding @Output and EventEmitter in Angular

Two Problems of a JavaScript Class


Starting ECMA 6, JavaScript has class keyword to create a class. I have written in detail about class here. There is no second question that class simplifies the way object is created, inheritance is implemented etc. JavaScript class has,

  • Constructors
  • Methods
  • Extends etc.

Above features of a class helps to easily write Object Oriented JavaScript. As a developer, you do not need to know complexities of prototype chains, relationship between function constructor and its prototype object, and value of object’s __proto__ properties etc. to write effective Object Oriented JavaScript.  So, class keyword  is good addition to JavaScript language, however it is not gospel perfect. It has some problems, which may restrict you to write full-fledged Object Oriented JavaScript. In this post, I am going to share two such problems. Read along,

No Static Member Properties in class

A static member property is shared by all object instance of the class. JavaScript class does not allow creating it inside the class.

You cannot declare properties directly in the class. You can only have it through class’s constructors, and properties created inside constructor is local to the object instances and not shared by all of them.

Above code will throw error “unexpected identifier”.  There is a work around to create static property using the class prototype.

Now on the instances of Speaker class, you can access static property count.

Therefore, you are able to create a static property, but not without help of understanding of prototype.  In my opinion class should have a way to create static property directly inside the class like a method or constructor.

Object instances does not copy definitions from class

To understand this problem, let us first revise Constructor Invocation Pattern and prototype chain. You have a function constructor Speaker.

Using new operator, you can create object instances,

In this approach, a and b object instances both have their own copy of hello method.  Now if you add a hello method to Speaker.prototype, still a and b object instances will access their own copy of hello method. Consider below code:

Read full article on the Infragistics blog

How to add a static member property in a JavaScript class?

Recently while solving a problem, I came across a requirement to create a property in a JavaScript class, which needs to be shared by all the object instances. In the programming world, these types of properties are called Static Properties.

There are various scenarios when you need a static member property:

  • When counting number of object instances created from a particular class
  • When logging some information at the class level instead of object instance level, etc.

To create a static property, you should know two important things:

  1. A JavaScript class cannot have a member property. You can only create it using a constructor
  2. Like the function constructor, a JavaScript class also has a prototype

Well, if you are a champion of prototypes, you must have guessed the answer in your mind by this time.  Any way, let us move forward to see the implementation,

Read full article on the Infragistics blog

Free Download – Angular Essentials E-Book to help you getting started

Are you new to Angular and just starting with it? Well, I have written a small eBook for you, which you may find useful.

You can download it free from here


This book does not contain everything of Angular. It just contains topic you need to get started with Angular.

In these 10 pages E-Book, you will learn about:

  1. Angular’s basic architecture: NgModules, Components, Templates, Directives, Two-way Data Binding, Services, Dependency Injection, and Routing
  2. Setting up an environment: Downloading Angular with the Angular CLI tool; must have Node.js and npm installed
  3. Components: What you see in the browser. Consists of the following parts: a TypeScript class called the Component Class, an HTML file called the template of the component, and an optional CSS file for styling the component
  4. Data binding: Determines how data will flow in between the component class and component template
  5. Component communication: For sharing data (object, string, number, array, HTML)
  6. Directives: Creating DOM elements and changing their structure or behavior in an Angular application

Download it free from here

As I told you, this book is only 10 pages long and it contains basic minimum you need to get started with Angular. Currently I am writing a complete Angular Essentials Book, send me your feedback and I will try to incorporate them. You can reach me at debugmode[at]outlook[dot]com

I hope you find Angular Essentials Ref Card useful. Thanks!

Content Projection in Angular Element with Slot in Angular 7.0

In this article, we will learn how to project content in an Angular Element. If you are unfamiliar with the following,

  • Shadow Dom
  • ViewEncapsulation
  • Content Projection

I recommend you read the articles below before moving forward:


As of now, you know that we use ng-content to carry out content projection as shown in the next listing:

You can also project content as shown in the next listing:

The challenge with the above approach is, “If you use GreetComponent as your Angular Element,” you will not able to project content. To understand this better, let us start with converting GreetComponent to an Angular Element.  Here you can Learn Step by Step tp Create Angular Element.

After converting GreetComponent as Angular Element, AppModule should look like the listing below:

Now you can use GreetComponent on index.html as shown in the listing below:

Upon running the application, you will find that the <h2> element has not been projected to the Angular Element GreetComponent.

Read full article on the Infragistics blog

How to Create Basic Inheritance in JavaScript Constructors

There are four ways to create an object in JavaScript. They are as follows:

  1. Object as literal
  2. Constructor Invocation Pattern
  3. Object.create() method
  4. Using class after ES6

Implementation of Inheritance varies according to the object creation method. In this post, I am going to explain creating inheritance in between a function constructor.

Let’s say you have a function:

If you call the animal function using new operator, an object will be created. This way of object creation is also known as “Constructor Invocation Pattern

Object dog and cat both have their own names and age properties. If you want a property or method to be shared across all objects, add that to the prototype of the function.

Using the JavaScript prototype chain, both dog and cat objects can access the canRun method.

Next, let us create another constructor – human:

At this point in time, human and animal functions do not have any relationship. However, we know that human is also an animal. There are two problems with the human constructor.

  1. It has duplicate codes for name and age initialization. It should use animal constructor for this purpose.
  2. It does not have any link with animal constructor

The above said two problems can be removed by creating inheritance in between animal and human function constructors.

You can solve problem 1 of code duplication by modifying the human function as below:

Now, in human function, we are using the call method to manually pass a current object as a value of ‘this’ in animal function. This approach is also called Indirect Invocation Pattern. Now, an object instance for human can be created as shown below:

So far, we have solved problem 1 of code duplication; however, human function is still not linked to animal function. If you try to call canRun method on h1 object, JavaScript will throw you an error.

You can fix this problem by linking the prototype of the human function with the prototype of the animal function constructor. There are two ways to do that.

  1. Using __proto__
  2. Using Object.create() method

You can link prototype of function constructors using Object.create() as shown below:

You can link prototype of function constructors using __proto__ as shown below:

I would prefer the Object.create() method because__proto__ may not be supported in many browsers. After linking prototypes, in one way, you have created inheritance in between animal and human function constructors. Object instance of human can read all properties of animal function and can execute animal function methods.

Read full article on the Infragistics blog here