0

Why are some methods called from the base, while others are called from the prototype of an object?

For instance String.fromCharCode() is a base method as opposed to String.prototype.charAt() and String.prototype.indexOf() which are prototype methods.
Why are not all methods of built-in objects called in the same way?

Petrus K.
  • 840
  • 7
  • 27
  • 56
  • 1
    You might want to read http://stackoverflow.com/questions/1635116/javascript-class-method-vs-class-prototype-method I think it answer to your question – user3 May 29 '16 at 00:24
  • 1
    `fromCharCode` is a factory method, it generates a new string, whereas the other methods work on an existing string. – Felix Kling May 29 '16 at 00:25
  • Thanks, wasn't sure if this was answered in other threads. I searched for "javascript call base method vs prototype" but only came up results that didn't answer my question, like: http://stackoverflow.com/questions/560829/calling-base-method-using-javascript-prototype – Petrus K. May 29 '16 at 00:27

0 Answers0