[removed] What are .extend and .prototype used for?

前端 未结 7 1011
渐次进展
渐次进展 2020-12-02 04:40

I am relatively new to JavaScript and keep seeing .extend and .prototype in third party libraries I am using. I thought it had to do with the Prototype javascript library, b

相关标签:
7条回答
  • 2020-12-02 05:27

    .extend() is added by many third-party libraries to make it easy to create objects from other objects. See http://api.jquery.com/jQuery.extend/ or http://www.prototypejs.org/api/object/extend for some examples.

    .prototype refers to the "template" (if you want to call it that) of an object, so by adding methods to an object's prototype (you see this a lot in libraries to add to String, Date, Math, or even Function) those methods are added to every new instance of that object.

    0 讨论(0)
提交回复
热议问题