Tuesday, 15 July 2014

Escaping "this" or @ character in coffeescript -



Escaping "this" or @ character in coffeescript -

accessing web api i'm getting json response similar to:

example: { @param: 1 }

in javascript, access example.@param in coffeescript, @ reserved word , shortcut this throws error "parse error on line #: unexpected '@'".

how can access variable?

in coffeescript

e={"@param":1}

then

e["@param"] # @param value

e={@param:1} not valid javascript if @param not surrounded quotes , valid json because in json keys must quoted.

coffeescript

No comments:

Post a Comment