aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-10-16 21:01:22 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-10-16 21:01:22 -0700
commite91161817c388eb4d759cbf9730f11df9a949f45 (patch)
treec2ea81fc7b337f632dc81c7caf910f3ed6a89dc2 /src/preamble.js
parent350fa1956b8f3c371c964947070d5614aa8c9e78 (diff)
properly use console.log on the web
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/preamble.js b/src/preamble.js
index c8f93b56..1fec1301 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -655,8 +655,10 @@ Module['String_copy'] = String_copy;
// Tools
-if (typeof print === 'undefined') {
- this['print'] = console.log; // we are on the web
+if (typeof console === 'object' && typeof console.log === 'function') {
+ this['print'] = function(x) { console.log(x) }; // web console
+} else if (typeof print === 'undefined') {
+ this['print'] = function(){}; // harmless no-op
}
// This processes a JS string into a C-line array of numbers, 0-terminated.