logo

/Code Snippet|v2.3.3

Module

Static Methods

createObject(obj)createObject.jsline 17

Create a new object with the specified prototype object and properties.

PARAMETERS
NameTypeDescription

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
NameTypeDescription

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) {
  // ...
};
Resizable