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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -