Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 799 Bytes

.verb.md

File metadata and controls

26 lines (19 loc) · 799 Bytes

About

A symbol is a unique and immutable data type and may be used as an identifier for object properties. The symbol object is an implicit object wrapper for the symbol primitive data type. - Mozilla Developer docs for Symbol

Usage

const assignSymbols = require('{%= name %}');
let target = {};

// add a symbol to object "one"
let one = {};
let symbolOne = Symbol('aaa');
one[symbolOne] = 'bbb';

// add a symbol to object "two"
let two = {};
let symbolTwo = Symbol('ccc');
two[symbolTwo] = 'ddd';

// assign symbols from objects "one" and "two" to object "target"
assignSymbols(target, one, two);

console.log(target[symbolOne]); //=> 'bbb'
console.log(target[symbolTwo]); //=> 'ddd'