-
-
Notifications
You must be signed in to change notification settings - Fork 868
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Good work, @jaredgalanis. Please review the changes I suggested and let's continue from there.
source/getting-started/js-primer.md
Outdated
|
||
### Property intializer syntax | ||
|
||
Now properties can be set on object literals without by including the name of the property without the typical colon and value if the object property the same as the local variable you intend to set as the value of that property. This helps reduce duplication. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need Now
to begin the sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, see if you can provide example of how it's done currently:
function someFunc(thing1, thing2) {
return {
thing1: thing1,
thing2: thing2
};
}
then move on to describe how the new syntax makes it simpler. Just so the learner doesn't have to conjure things up in their mind. Also remind them that it doesn't apply in cases where object key isn't equal to value. And that both old and new style can be mixed.
source/getting-started/js-primer.md
Outdated
|
||
## Object Literal Shorthand | ||
|
||
In ES6 some functionality was added that allows the use of terser syntax for object literal properties and methods, along with some enhanced functionality for property names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of "ES6 introduced a new syntax for object literals ..." as the opening line. I'm not too comfortable with some functionality was added
. If that's just me feel free to ignore this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaredgalanis Good work! I think there's only a few more changes for your consideration and we're good to go.
source/getting-started/js-primer.md
Outdated
|
||
For example: | ||
Can be written like this in ES6 using the property initializer syntax: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! @jaredgalanis what do you think about saying can be written, in ES6, as:
? I believe the learner wouldn't have lost the context (the new property initializer syntax) by now and so we don't have to remind them.
source/getting-started/js-primer.md
Outdated
|
||
### Property intializer syntax | ||
Properties can now be set on object literals by including the name of the property only without the typical colon and value. This prevents some duplication when the object property is the same as the local variable you intend to set as the value of that property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can expand this a little further. ES6's initializer syntax works if and only if the property name is the same as the variable holding the value to be assigned to it. For example, while this works
let firstName = 'Ember';
let lastName = 'Tomster';
let tomster = {
firstName,
lastName
}
this won't
let nombre = 'Ember';
let apellido = 'Tomster';
let tomster = {
firstName,
lastName
}
because the variables holding the values are different than the object's properties.
@jaredgalanis Another thing but I don't know how hard that will be. Is it possible to replace |
Thanks @yawboakye. I tried revising things in the way you suggested. Note that I also took out the final section about computed property names. My thinking is that subject is too far down in the weeds for what is meant to be covered here. Especially since it's only new to ES6 in the sense that they can be used with object literals (vs instances). |
LGTM. @locks? |
As requested by #1751 @locks. Heads up @rtablada.