Javascript OOP library for client and server js (node.js)

Is there any Javascript OOP library that can easily work with classes, property, etc. more based on classes, in order to avoid the OOP prototype that works with JS both on the client (browser) and on the server (in my case Node.js, but usually it uses the main javascript functions, so they can be used regardless of the interpreter)?

Thank.

+3
source share
4 answers

The Rightjs library has a server assembly you can download .

I think he means Node.js.

On the download page:

RightJS . JavaScript , Observer, Options -DOM Util.

CommonJS Node.js.

+3

https://github.com/alessioalex/Cls 3 . , 3 ( mixin , Cls, ).

Node.js , .

:

var Person = Cls({
  methods: {
    constructor: function(name, age) {
      this.name = name;
      this.age = age;
    },
    present: function(otherDude) {
      return "Hello " + otherDude + " I'm " + this.name + ", my age is: " + this.age;
    }
  },
});

var Student = Cls({
  // extends the Person class
  uber: Person,
  present: function() {
    /**
     * call super function
     * note that this approach works even async (unlike other class libs)
     */
    return this.inherited('present', arguments);
  }
});

/**
 * since the constructor is missing
 * it will call the super constructor automatically
 */
var alex = new Student('Alex', 25);
alex.present();
+1

A couple of days ago, Dirk Ginader, a supporter of Yahoo !, told me that the latest version of YUI3 works flawlessly with node.js.

I did not confirm that myself (not a big fan of YUI), but Dirk works for Yahoo! which will be released (partially) based on node.js. This is good enough for me to believe that he knew what he was talking about :-)

0
source

Source: https://habr.com/ru/post/1769416/


All Articles