First I would like to say that explaining this using images might make it easier for me to understand how it works.
I’m trying to learn how this works:
JavaScript delete operator
Where would console log be placed in the code?
console.log(playerVars.width);
And what should I be seeing inside the browser?
I placed it here:
The only thing that comes up in the browser is: undefined
And what’s the reason why we added delete playerVars there to begin with?
What was happening that we didn’t want to happen?
By adding “delete playerVars” we’re preventing what from happening?
const video = wrapper.querySelector(".video");
const width = opts.width || 198;
const height = opts.height || 198;
const playerVars = opts.playerVars || opts;
delete playerVars.width;
delete playerVars.height;
console.log(playerVars.width);
videoPlayer.init(video, {
width,
height,
playerVars
});
We can use this image as an example:
When delete is being used on width and height that would mean that, the video in the middle, where it was opened, that would return True, and all the unopened squares would return False?
Is that how it works?
This would mean that, those given properties, width, height would only be given to the squares where the videos are being shown, right? And where there are no videos being shown, those would be given no property value, unless and until it’s clicked on.
delete playerVars.width;
delete playerVars.height;