Created
August 28, 2014 10:59
-
-
Save lulezi/e50f0fabce9aaa827360 to your computer and use it in GitHub Desktop.
Quick Fix for ember.js error "Cannot convert object to primitive value"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inspect(obj) { | |
var type = typeOf(obj); | |
if (type === 'array') { | |
return '[' + obj + ']'; | |
} | |
if (type !== 'object') { | |
return obj + ''; | |
} | |
var v; | |
var ret = []; | |
for(var key in obj) { | |
if (obj.hasOwnProperty(key)) { | |
v = obj[key]; | |
if (v === 'toString') { continue; } // ignore useless items | |
if (typeOf(v) === 'function') { v = "function() { ... }"; } | |
if (typeOf(v) === 'object') { v = '[object]'; } | |
ret.push(key + ": " + v); | |
} | |
} | |
return "{" + ret.join(", ") + "}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add line #17 to fix ember.js error "Cannot convert object to primitive value". Use at your own risk!