In JavaScript, an object can have two types of properties: data(standard) properties and accessor properties. Every property in an object has some attributes, this blog post we are going to take a look at the attributes of data properties. The data properties have the following four attributes: [[Configurable]] – Determines whether we can change the…
There are multiple ways to iterate/loop through all the properties in a JavaScript object.
Method 1: for-in loop
var person = {
name: 'Shravan Kasagoni',
age: 20,
isActive: true
};
person.constructor.prototype.printName = function() {
console.log(this.name);
};
person.constructor.prototype.encKey = 'somevalue';
person.constructor.prototype.printName = function() {
console.log(this.name);
};
The for-in loop iterates over all enumerable properties of an object.
for (var propertyName in person) {
console.log(propertyName, person[propertyName]);
}
Result:
name Shravan Kasagoni
age 20
isActive true
printName ƒ () {
console.log(this.name);
}
encKey somevalue
Destructuring is a new feature in ECMAScript 2015. Destructuring allows binding a set of variables to a corresponding set of values (objects and arrays) anywhere we can bind a value to a single variable. Today we are already doing destructuring (extracting values) almost in every JavaScript program, but we do it manually. To understand destructuring…
I have been exploring and working on ECMAScript 2015 (formerly know as ECMAScript 6/ES6). I am going to blog about all the new ECMAScript 2015 features. Here is the list of blogposts: Destructuring in ECMAScript 2015 Spread Operator in ECMAScript 2015
Follow the below steps to use ECMAScript 2015 (formerly known as ECMAScript 6) while writing gulp file. Step 1: From gulp 3.9 version onwards we can use ECMAScript 2015, so make sure you installed the latest version of gulp into your project. Check the gulp version before proceeding, run the following command at root of…