I am defining dynamic variables in a way that works fine in Chrome:
id = parent.data('parent_id')
$.ajax
...
success: (res, status, xhr) ->
alert(res.results.slice(0,4)) # gives '[object Object],[object Object],[object Object],[object Object]' in Chrome and FF
window[id] = res.results.slice(0,4) # works fine to set in Chrome
console.log(window[id]) # gives correct object in Chrome, 'undefined' in FF
...
However, when I try to use the same syntax in Firefox, I get TypeError: obj is undefined
in the FF console and console.log(window[id])
writes "undefined" as well.
What is the correct approach/syntax to get this working in both Chrome and Firefox?
EDIT
alert(res.results.slice(0,4))
gives [object Object],[object Object],[object Object],[object Object]
in both Chrome and Firefox right before I try to define window[id]
, so the object has been defined at that point.
EDIT 2
Example found here: http://jsfiddle.net/8Wk9J/. Works in Chrome but gives undefined
in Firefox