I have this function that I'm using it in a Rails 3.1 project:
setPosition: (object) ->
console.log object
console.log object.width
object["position"] = [500, 50]
this
The console.log object gives
Object
height: 600
position: Array[2]
title: "Banner for Creative"
width: 160
__proto__: Object
but console.log object.width is undefined. Why ?
object, use a more descriptive name that avoids ambiguity with native objects.console.log (x for x of object)andconsole.log 'width' of object? It may be that there's a subtle string issue, such as the key name having a null character at the end. See my answer on another question today: stackoverflow.com/a/8344503/66226