search

Home  >  Q&A  >  body text

JavaScript native reference types

Do the native reference types in JavsScript, such as the Object type, use the constructor pattern?

淡淡烟草味淡淡烟草味2800 days ago1009

reply all(3)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-12 09:32:53

    js is a language based on prototypal inheritance. At the beginning of the creation, I referred to Scheme, which uses functions as first-class citizens, the syntax of C language, and the prototypal inheritance of self language, so it is a combination of the advantages of the three; it was originally called LiveScript, but Java was very popular at the time, so the company changed its name. It's called JavaScript, but actually it has nothing to do with java.
    The advantage of prototypal inheritance is that it allows multiple inheritance and can simulate classes, but class languages ​​can never simulate prototypes. This is the flexibility of JavaScript, which can be used for both functional programming and object-oriented programming.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-12 09:32:53

    http://www.cnblogs.com/wangfu...

    reply
    0
  • PHP中文网

    PHP中文网2017-06-12 09:32:53

    Classes and objects in JavaScript are inherently controversial because they use prototypal inheritance, which is inheritance achieved by referencing methods on the prototype chain. The methods on the object you call will ultimately call the methods above Object.prototype. Even if these methods are not defined using new but are defined using object literals, they can still be called.
    That is, if you modify the method on Object.prototype, then the method called by all objects will change. All constructors in JavaScript are actually faked using prototypal inheritance. Even the newly added class in ES6 is essentially implemented using prototypal inheritance. So we still need to have a deeper understanding of how prototypal inheritance is implemented.

    reply
    0
  • Cancelreply