Question #91

Author: admin
tags: JavaScript  
const func1 = () => { return 1; };
const func2 = func1;

const map = new Map();

map.set(func1, 'hello');

console.log(map.get(func1)); // #1
console.log(map.get(func2)); // #2
console.log(map.get(() => { return 1; })); // #3
console.log(map.get('hello')); // #4
In which lines will the value 'hello' be output to the console?
#1
#2
#3
#4
The Map object holds key-value pairs.
Any JS-value may be used as either a key or a value.
In line:
const func2 = func1;
the function was copied by a reference.
In line:
console.log(map.get(() => { return 1; })); // #3
we created new function, so it has other reference.
Rate the difficulty of the question:
easyhard