3 new object initialization shorthand notations were added to with ES2015: Shorthand property names, Shorthand method names, Computed property names. Objects initialization by default can be done using Object.create(), new Object or the literal notation by using an object initializer. There are ways to make this initialization concise in specific scenarios and we are going to go through those shorthands in this post.
I was recently working on a project in which I was trying to use a shorthand notation for destructuring assignment of a variable. I was researching different ways of getting a specific scenario to work. And while doing that research, I found that ES2015 had added 3 new object initialization shorthand notations that I had not known existed. And so I decided to share these with everyone.
Note: As with most good things, these do not work with Internet Explorer. So if you are supporting it, these still might be good to have in your arsenal when Microsoft drops support for IE later.
Objects initialization by default can be done using Object.create()
, new Object
or the literal notation by using an object initializer. The object initializer has been one of the most common ways:
const foo: {
bar: 1,
baz: 2
}
There are ways to make this initialization concise in specific scenarios and we are going to go through those shorthands in this post.
3 new object initialization shorthand notations were added to with ES2015:
With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...
You name the business and I will tell you how web development can help you promote your business. If it is a startup or you seeking some...
We are the best offshore web development company in India providing web applications on Blockchain, AI & Chatbots. 15+ Yrs Exp., Save upto 60% on development.
Hire Dedicated JavaScript Developers from a top javascript development agency for your business solutions. We provide JS web developers for hire at a fixed or hourly rate.
Temporal dead zone in JavaScript (TDZ) is one of the topics every JavaScript developer should know. This tutorial will teach you all you need to know about it. You will learn what temporal dead zone in JavaScript is and how it works. You will also learn about scope and variable declaration and initialization.