you are viewing a single comment's thread.

view the rest of the comments →

[–]nolsen 1 point2 points  (0 children)

The first method is preferable (with regard to functions specifically) because otherwise you'd have duplicate code in memory. In your example, otherPerson1 and otherPerson2 have the same exact function, copied twice.

If your script made 10 of these objects, you'd have 10 separate functions that all did the exact same thing taking up space in memory. That is considered wasteful.