dwyl / dwyl/learn-javascript

ES6 Object Litteral Shorthand Notation?

Open
#15 0 comments 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
HTML
Stars
65
Forks
15
PR merge metrics
No merged PRs in 30d

Description

This is a _reasonably_ good/useful feature: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_2015
it allows us to do the following:

``` js
// imagine that there are already variables in your script/app for name and email
var obj = {
name,
email
}
```

instead of having to _type_ out the _values_ for the fields in the `Object`:

``` js
// imagine that there are already variables in your script/app for name and email
var obj = {
name: name,
email: email
}
```

The JavaScript engine _infers_ what the _values_ are given the names of the keys in the `Object`...

Given that _most_ browsers _don't_ support this...
![es6-object-literal-shorthand-notation](https://cloud.githubusercontent.com/assets/194400/12127256/0d4190d8-b3ee-11e5-9191-8c4a532ad59f.png)
I will be using it _selectively_...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.