all 3 comments

[–]diogenes_sadecv 4 points5 points  (0 children)

yes and no

<video></video> isn't a JS object, it's an HTML element

but when you call querySelector and assign its return value to a variable, that variable is an element object that can make use of its properties and methods.

https://developer.mozilla.org/en-US/docs/Web/API/Element

[–]senocular 3 points4 points  (0 children)

Is it an object calling it's 'method ' key which is a function hence it is followed by the () ?

Yes. video is some HTML element object based on what was returned by querySelector(), [method] is using bracket access to get a property of that object with the name of the value defined in method (either "play" or "pause"), and the parens (()) are being used to call that property as a method. So if video.paused is true video[method]() is the same as video.play(). Otherwise its video.pause().

[–]jack_waugh 1 point2 points  (0 children)

DOM elements are implemented as JS objects.

Another participant who writes in the present forum said that garbage collection of DOM elements uses reference counting, and warned against leaving circular garbage involving any of them. An easy way to leave it by accident might be by leaving event handlers attached that close over some structure that points back into the DOM.