This can be written so many different ways I’m confused and don’t know which should be used.
If I do this:
This would then be deleted: const players = [];
Do you want me to do this? This works.
https://jsfiddle.net/vsqezghc/
const player = new YT.Player(video, playerOptions);
return player;
}
The code originally used this: Code 1 https://jsfiddle.net/k24ecz8t/
const player = new YT.Player(video, playerOptions);
players.push(player);
}
You wanted me to do this: Code 2 https://jsfiddle.net/Lukx134r/
const player = new YT.Player(video, playerOptions);
}
Where I get this in jslint:
Unused ‘player’.
const player = new YT.Player(video, playerOptions);
Full Code 1
const players = [];
function addPlayer(video, playerOptions) {
playerOptions.videoId = playerOptions.videoId || video.dataset.id;
playerOptions.events = playerOptions.events || {};
playerOptions.events.onReady = onPlayerReady;
playerOptions.events.onStateChange = onPlayerStateChange;
const player = new YT.Player(video, playerOptions);
players.push(player);
}
Full Code 2
const players = [];
function addPlayer(video, playerOptions) {
playerOptions.videoId = playerOptions.videoId || video.dataset.id;
playerOptions.events = playerOptions.events || {};
playerOptions.events.onReady = onPlayerReady;
playerOptions.events.onStateChange = onPlayerStateChange;
const player = new YT.Player(video, playerOptions);
}
Should one of these be used?
Code works using this: https://jsfiddle.net/sczvwo2f/
const player = new YT.Player(video, playerOptions);
players.push(player);
}
Code works also using this: https://jsfiddle.net/z0f6sd87/
players.push = new YT.Player(video, playerOptions);
}