Specifically, if I have some json:
var myData = [ 'some info', 'some more info' ]
var myOtherData = { someInfo: 'some more info' }
What’s the correct CoffeeScript syntax for that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to create an array you can use
myData = ['some info', 'some more info']If you want to create an object you can use
myData = {someKey: 'some value'}Or you can use just
myData = someKey: 'some value'(i.e. you can omit the{})For more complicated object structures you use indentation with optional
{}and optional commas, for examplewill result in the variable myData containing an object with the following JSON representation, (which also happens to be valid CoffeeScript):