Skip to content

Instantly share code, notes, and snippets.

@daytonn
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daytonn/3c88d1d996d2e919ef3b to your computer and use it in GitHub Desktop.
Save daytonn/3c88d1d996d2e919ef3b to your computer and use it in GitHub Desktop.
CWCPOOJS - bad instantiation
function Person(attributes) {
this.firstName = attributes.firstName;
this.lastName = attributes.lastName;
this.age = attributes.age;
this.address = attributes.address;
}
var bob = Person({
firstName: "Bob",
lastName: "Ject",
age: 33,
address: {
street: "123 Memory Ln",
apt: "0x7fff9575c05f",
zip: "01101",
city: "Browser Town",
state: "Mozilla"
}
);
console.log(bob); // undefined
console.log(window.firstName); // "Bob"
console.log(window.lastName); // "Ject"
console.log(window.age); // 33
console.log(window.address); // [object Object] (address object)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment