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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -