new Enum(itemList)enum.jsline 68
Make a constant-list that has unique values.
In modern browsers (except IE8 and lower),
a value defined once can not be changed.PARAMETERS
Name Type Description itemList
stringArray.<string>
Constant-list (An array of string is available)
EXAMPLES
// CommonJS const Enum = require('tui-code-snippet/enum/enum'); const MYENUM = new Enum('TYPE1', 'TYPE2'); const MYENUM2 = new Enum(['TYPE1', 'TYPE2']); // usage if (value === MYENUM.TYPE1) { // ... } //add (If a duplicate name is inputted, will be disregarded.) MYENUM.set('TYPE3', 'TYPE4'); //get name of a constant by a value MYENUM.getName(MYENUM.TYPE1); // 'TYPE1' // In modern browsers (except IE8 and lower), a value can not be changed in constants. const originalValue = MYENUM.TYPE1; MYENUM.TYPE1 = 1234; // maybe TypeError MYENUM.TYPE1 === originalValue; // true *
Resizable