I wonder whether the JavaScript alert function in the browser needs the document as this parameter or not. So what is the correct call via apply?
/* Variant 1 */
alert.apply(null, ["Hello World!"])
/* Variant 2 */
alert.apply(window, ["Hello World!"])
An answer to the above question might also discuss bind and call, but I would be already happy if somebody could enlighten the apply case.
Edit 25.06.2021:
It seems that alert is not "normal", I get inside some fiddle:
/* Variant 3 */
alert.apply(document, ["Hello World!"]);
-->
Error: 'alert' called on an object that does not implement interface Window.
Aucun commentaire:
Enregistrer un commentaire