Example
(str #js {"toString" (fn [] "hello") "valueOf" (fn [] 42)}) ; => "42"
The problem in the fact that ClojureScript uses concatenation to convert values to strings and that doesn't work well with objects which have valueOf() method overriden.
Example in js:
var obj = { toString: function() { return 'hello'; }, valueOf: function() { return 42; } }; console.log(String(obj)); => 'hello' console.log(obj.toString()); => 'hello' console.log('' + obj); => '42'
Potential solution might be to use String() function. Using toString() won't work as described in this issue: http://dev.clojure.org/jira/browse/CLJS-847
Example
(str #js {"toString" (fn [] "hello") "valueOf" (fn [] 42)}) ; => "42"The problem in the fact that ClojureScript uses concatenation to convert values to strings and that doesn't work well with objects which have valueOf() method overriden.
Example in js:
var obj = { toString: function() { return 'hello'; }, valueOf: function() { return 42; } }; console.log(String(obj)); => 'hello' console.log(obj.toString()); => 'hello' console.log('' + obj); => '42'Potential solution might be to use String() function. Using toString() won't work as described in this issue: http://dev.clojure.org/jira/browse/CLJS-847