Month: June 2020
-
How to make a property non-enumerable in JavaScript?
By default, all the properties of JavaScript objects are enumerable. That means you can enumerate them in a for loop or read them using the Object.values(). Let us consider an object Dog as shown below, You can enumerate all properties and read their values using the for loop or Object.values() method as shown below, Now…
-
How to merge arrays using spread operator in JavaScript?
Have you come across a requirement to merge two or more arrays into another array? Let us say, you have two arrays as shown below, You need to merge them in another array with optional extra elements in the resultant array. JavaScript array spread operator makes it very simple to merge arrays. You can merge…
-
How to create Private Properties in JavaScript.
We don’t have Access Modifiers in JavaScript, and all properties of an object are public, which means you can read and modify them outside the object. But what if you have a requirement to create private properties? Consider Product object as mentioned below, By default, JavaScript allows you to read and modify all the properties.…
-
How to use different syntax for Angular Interpolation
How to use different syntax for Angular Interpolation