defineClassdefineClass.jsline 60
Static Methods
defineClass(parent, props)defineClass.jsline 60
Help a constructor to be defined and to inherit from the other constructors
PARAMETERS
Name Type Description parent
[ * ]
Parent constructor
props
Object
Members of constructor
PROPERTIES
Name Type Description init
Function
Initialization method
static
[ Object ]
Static members of constructor
RETURNS:
{*
} - ConstructorEXAMPLES
// ES6 import defineClass from 'tui-code-snippet/defineClass/defineClass'; // CommonJS const defineClass = require('tui-code-snippet/defineClass/defineClass'); //-- #2. Use property --// const Parent = defineClass({ init: function() { // constuructor this.name = 'made by def'; }, method: function() { // ... }, static: { staticMethod: function() { // ... } } }); const Child = defineClass(Parent, { childMethod: function() {} }); Parent.staticMethod(); const parentInstance = new Parent(); console.log(parentInstance.name); //made by def parentInstance.staticMethod(); // Error const childInstance = new Child(); childInstance.method(); childInstance.childMethod();