Skip to content

JavaScript 101 Types: Removed new Object suggestion #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2014

Conversation

gnarf
Copy link
Member

@gnarf gnarf commented Aug 4, 2014

"The simplest way" is to use an object literal. None of us use new Object we shouldn't even mention it.

@gnarf
Copy link
Member Author

gnarf commented Aug 4, 2014

cc @ajpiano @kswedberg @rwaldron for review/further edit suggestions please?

@mgol
Copy link
Member

mgol commented Aug 4, 2014

Yeah, definitely 👍

alert( people[ "person1" ].firstName );
alert( people[ "person2" ].firstName );
```

If a property is accessed that has not been defined, it will return a type of `undefined`.
If a property is accessed that has not been defined, it will be the value `undefined`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will have the value, rather than be the value?

@kswedberg
Copy link
Member

@gnarf: Much better!

@gnarf
Copy link
Member Author

gnarf commented Aug 4, 2014

Updated with Karl's suggestion - going to wait for at least one more set of eyes before landing

people[ "person1" ] = person1;
people[ "person2" ] = person2;

// Access properties using a mix of both bracket and dot notaion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: notaion

@scottgonzalez
Copy link
Member

Other than the one typo, this looks good.

@gnarf gnarf merged commit 03e9df2 into jquery:master Aug 4, 2014
@gnarf
Copy link
Member Author

gnarf commented Aug 4, 2014

Fixed typo and landed

@gnarf gnarf deleted the new-object branch August 4, 2014 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants