Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript object as key

var fighters = new WeakMap();
var bruce = {name: 'Bruce Lee'};
var chuck = {name: 'Chuck Norris'};

fighters.set(bruce, 'Jeet Kune Do');
fighters.set(chuck, 'Karate');

console.log(fighters.get(bruce)); // Jeet Kune Do
console.log(fighters.get(chuck)); // Karate
Source by www.hacksparrow.com #
 
PREVIOUS NEXT
Tagged: #javascript #object #key
ADD COMMENT
Topic
Name
7+6 =