What are the small and fast javascript OOP libraries. Which allow you to create classes, inherit from them? In such a style.

// объявляСм класс Lib.defineClass('имя_класса' ,{ extend: 'Ρ€ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΡΠΊΠΈΠΉ_класс', // наслСдуСмся ΠΎΡ‚ Ρ€ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒΡΠΊΠΈΠΉ_класс myProp: [1,2] }); // Π‘ΠΎΠ·Π΄Π°Ρ‘ΠΌ экзСмпляр(ΠΎΠ±ΡŠΠ΅ΠΊΡ‚) класса с Ρ‚ΠΈΠΏΠΎΠΌ имя_класса, замСняя свойство myProp. var cls = Lib.createClass('имя_класса' ,{ myProp: [1,2,3,4], myProp2: 'свойство экзСмпляра класса' }); cls.myProp[0]; // 1 Lib.имя_класса; // созданный класс доступСн ΠΊΠ°ΠΊ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ Π³Π΄Π΅ Π½ΠΈΠ±ΡƒΠ΄ΡŒ. Lib.имя_класса.myProp[0]; // 1 

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants Grundy , aleksandr barakin , VenZell , Streletz , insolor May 27 '16 at 10:23 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • how much should the library be small and how fast? What happens in the given piece of code? What is not satisfied with the native implementation? - Grundy
  • I need the same implementation as in Ext js. But in order for the file to weigh not 1 mb, and not more than 30 kb, and not be inhibited. An example added. First we declare a class, then we create a class object, then we access its property. - manking
  • The smallest 0 kilobyte is Object.create . - Aleksei Zabrodskii
  • Dean Edwards's Base Library - Alex Krass

2 answers 2

In fact, you do n’t need third-party libraries at all.

If you write ES6 code, you can use standard language tools:

 class Foo { constructor() { this.greeting = 'Hi all'; } sayHi() { console.log(this.greeting); } } class Bar extends Foo { sayHi() { console.log(this.greeting + ' from bar'); } } 

If you still haven't started using ES6, then the function that emulates class inheritance takes up only (attention) 10 lines . I already described exactly how inheritance works in JavaScript here in this answer . And here I just give the code of the inheritance function:

 var inherits = function(ctor, superCtor) { ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } }); } 

Well, standard language tools are quite suitable for defining classes.

    It may be suitable JS.Class Or you can search for something else on www.microjs.com