javascript - console.log method extraction from console -


considering console wasn't overriden , refers native object, console.log method (and possibly others) extracted console object with

var log = obj.log = console.log; // instead of console.log.bind(console) log(...); obj.log(...); 

is 100% safe in terms of browser , node compatibility?

a significant amount of js examples (maybe illustrative) bound console.log suggests may not.

browsers differ in console implementations, appears webkit/blink-based browsers (chrome, opera 15+, safari, etc) ones uncomfortable extracted console methods. browser compatibility extracted methods have bound:

var log = console.log.bind(console); 

node has own console implementation relies on this pre-binds methods. safe extract console methods in node applications, same applies electron's main process.

nw.js replaces node console chromium's:

node.js , chromium each has own implementation of settimeout , console. currently, console, use chromium's implementation everywhere, because can print in devtools , have more information exposed.

it not safe extract console methods in nw.js node's context.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -