Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
Creating a JavaScript object without the new keyword
(opens in new tab)
(davecooper.org)
3 points
gurgus
10y ago
6 comments
Save
Share
6 comments
3 comments · 1 top-level
top
newest
oldest
dskloet
10y ago
· 2 in thread
p2 is not an instance of Person. You also need to make sure p2's constructor is set to Person.
gurgus
OP
10y ago
Interesting - how can I go about this?
dskloet
10y ago
p2.constructor = Person;
Without that, the object also doesn't have the right prototype.
2 more replies
j
/
k
navigate · click thread line to collapse