Tag: object
-
How Object.entries work internally in JavaScript
In JavaScript, the Object.entries method returns an array of object’s own enumerable properties. It returns properties as a [key, value] pair, where the key is a string. You can read enumerable properties as an array of key-value pairs using the Object.entries method as shown below, let Product = { Title: ‘Book’, Price: 120, Author: undefined, inStock: true } console.log(Object.entries(Product)); Since it returns…
-
Video : Four ways of creating an object in JavaScript
There are four ways an object can be created in JavaScript object as a literal Using the new operator, also knows as constructor invocation pattern Using the Object.create() method Using the class starting ES6 Watch full video here : Source Code : This file contains bidirectional Unicode text that may be interpreted or compiled differently…
-
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: Enumerable Own Before we go ahead and understand purpose of Object.assign, it is essential that we really understand these two words,…
-
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…
-
How to Create Basic Inheritance in JavaScript Constructors
There are four ways to create an object in JavaScript. They are as follows: Object as literal Constructor Invocation Pattern Object.create() method 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…
-
What are getters and setters in JavaScript
In JavaScript, you may have heard of getters and setters. Let’s take a look at what these things are. First, a setter is used to set the value of a property. A setter gets called each time the value of the property is changed. In other words, it executes a function for each time a…
-
Objects in JavaScript for .NET developers – Part 1
Read full article on the Infragistics blog Here are some fun facts for you: JavaScript is not an object oriented language, but almost everything in JavaScript is an object. JavaScript does not have classes, and we can create an object from an object. A function can be used as a constructor, and returns a newly…
-
How to find index of an item in JavaScript Object Array?
Recently while working I came across a scenario. I had to find index of a particular item on given condition from a JavaScript object array. In this post we will see how to find index of object from JavaScript array of object. Let us assume we have a JavaScript array as following, Now if we…