Node.js 4.2.1 का निम्न कोड चलाते समय:क्या जावास्क्रिप्ट में ईसीएमएस्क्रिप्ट 6 कक्षा से पुरानी शैली की कक्षा का उत्तराधिकारी होना संभव है?
'use strict';
var util = require('util');
class MyClass {
constructor(name) {
this.name = name;
}
}
function MyDerived() {
MyClass.call(this, 'MyDerived');
}
util.inherits(MyDerived, MyClass);
var d = new MyDerived();
मैं निम्नलिखित त्रुटि मिलती है:
constructor(name) {
^
TypeError: Class constructors cannot be invoked without 'new'
मुझे आश्चर्य है अगर यह बिल्कुल संभव है ईसीएमएस्क्रिप्ट 6 कक्षाओं से पुरानी शैली की जावास्क्रिप्ट "कक्षाएं" प्राप्त करें? और, यदि संभव हो, तो कैसे?