inheritancecreateObject.jsline 17
Static Methods
createObject(obj)createObject.jsline 17
Create a new object with the specified prototype object and properties.
PARAMETERS
Name Type Description obj
Object
This object will be a prototype of the newly-created object.
RETURNS:
{Object
}
inherit(subType, superType)inherit.jsline 46
Provide a simple inheritance in prototype-oriented.
Caution :
Don't overwrite the prototype of child constructor.PARAMETERS
Name Type Description subType
function
Child constructor
superType
function
Parent constructor
EXAMPLES
// ES6 import inherit from 'tui-code-snippet/inheritance/inherit'; // CommonJS const inherit = require('tui-code-snippet/inheritance/inherit'); // Parent constructor function Animal(leg) { this.leg = leg; } Animal.prototype.growl = function() { // ... }; // Child constructor function Person(name) { this.name = name; } // Inheritance inherit(Person, Animal); // After this inheritance, please use only the extending of property. // Do not overwrite prototype. Person.prototype.walk = function(direction) { // ... };