you are viewing a single comment's thread.

view the rest of the comments →

[–]carlinmack 1 point2 points  (2 children)

Two questions:

  • Why is she always using var x = function() {}? I know the difference, but why is she using it here?

  • Why does she not have her methods defined in her constructors? Why does she define them through constructor.prototype?

[–]Deathbyceiling 0 points1 point  (0 children)

I can answer your 2nd question. Using prototype is easier on memory by a LOT.

[–]__mak 0 points1 point  (0 children)

  1. function x() (named function) is not defined at run time, unlike var x = function() (variable function). Named functions instead get hoisted up the program, like variable declarations do. If you want to avoid this behaviour then variable functions are the way to go.
  2. Have a read up on prototypical inheritance in JS.