I am trying to save an array of objects sent from the server side in a client side var but for some reason the var is a just a long string of
"[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]"
insted of the actual array.
my code is as follows
html.no-js(lang='en')
//<![end if]
head
script(type='text/javascript')
var x = '#{Countries}';
You need to encode them as JSON.
JavaScript:
JSON.stringify(Countries);
CoffeeScript: (I think)
JSON.stringify Countries
If you would like to convert this back into an objects, you use JSON.parse, as follows
JSON.parse(CountriesText);
(encoding in JSON would have to occur on the server-side node.js instance)