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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -