Is there any way to create variables with dynamic name?
for example :
i_1
, i_2
, i_3
, ... in which 1,2,3 numbers come from a for-loop
.
I tried this code but unfortunately does not work:
for(let i=0; i<10; i++) {
let `varibale_${i}` = 'some value';
}
UPDATE: I edited the code in this way based on suggestions in comment section but it does not work. Any suggestion really appreciated.
Is it possible to define these events in an object in global scope? Suppose we have these event listeners:
peer1.on('stream', () => console.log('do something'));
peer2.on('stream', () => console.log('do something'));
peer3.on('stream', () => console.log('do something'));
is it possible to define these events in an object like:
let obj = {
peer1: on('stream', () => console.log('do something')),
peer2: on('stream', () => console.log('do something')),
peer3: on('stream', () => console.log('do something')),
}