Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Reference error: 'console' is not defined
- StarscreamClone
-
1000+ posts
Reference error: 'console' is not defined
Alright, so when I type this into my JS compiler in my iPad application or on the compiler in Khan Academy, this error pops up. Is there a reason it's doing this when it will work fine in the Codecademy one?
Thank you,
Isaac
Thank you,
Isaac
- djdolphin
-
1000+ posts
Reference error: 'console' is not defined
this into my JS compiler in my iPad application or on the compiler in Khan Academy, this error pops up. Is there a reason it's doing this when it will work fine in the Codecademy one?What exactly do you mean by ‘this’? Alright, so when I type
Thank you,
Isaac
- scimonster
-
1000+ posts
Reference error: 'console' is not defined
The iPad probably doesn't support the console. 
You should probably define it at the top of your code as a fallback:
This won't break console.log() statements.

You should probably define it at the top of your code as a fallback:
var console = console || {log: function(){}};
- StarscreamClone
-
1000+ posts
Reference error: 'console' is not defined
I would have thought that, too, but it was built into the application, believe it or not. There are tons of 'em. The iPad probably doesn't support the console.
You should probably define it at the top of your code as a fallback:This won't break console.log() statements.var console = console || {log: function(){}};
Anyway, thank you so much. I appreciate it.

- Discussion Forums
- » Advanced Topics
-
» Reference error: 'console' is not defined