javascript - Why doesn't console.log work in the JSC environment but it works in Safari's debug console -


when use jsc (javascriptcore) engine provided in system library, acts differently when using safari's debug console

$ /system/library/frameworks/javascriptcore.framework/versions/a/resources/jsc >>> console.log("hello"); exception: typeerror: undefined not object (evaluating 'console.log') 

when console.log("hello"); works fine in safari.

tl;dr

var console = function () {     this.log = function(msg){ debug(msg) };  }; var console = new console(); console.log("hello"); 

safari creates console object available in debug console, not in jsc environment. see safari's console documentation here

adding own console object wraps jsc debug method solved problem:

$ /system/library/frameworks/javascriptcore.framework/versions/a/resources/jsc >>> var console = function () { ...     this.log = function(msg){ debug(msg) }; ... }; undefined >>> var console = new console(); undefined >>> console.log("hello"); -> hello undefined 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -