javascript - Why can't console.log be called using .call() -


the below code returns pop-up window 'hello'.

alert.call(this, 'hello'); 

but below code returns error "typeerror: illegal invocation".

console.log.call(this, 'hello'); 

what difference in implements of alert , console.log?

alert global method (window.alert). if call alert.call(this), this window object.

because log method in console object, expects this console object itself, still calling this(window), error.

running console.log.call(console, 'test') work fine.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -