Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
ww520
on April 30, 2012
|
parent
|
context
|
favorite
| on:
OO JS in 15mins or Less
So that the methods don't need to be re-defined for every object.
recursive
on April 30, 2012
[–]
Object literals don't require you to duplicate any code:
function getObject(val1, val2) { return { foo: val1, bar: function() { return val2; } }; }
stephenr
on May 1, 2012
|
parent
[–]
In this instance the "bar" method is redefined every time you call getObject.
Consider applying for YC's Summer 2026 batch! Applications are open till May 4
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: