5 ms·
Oh dude, just learned something new from this article. options = { a b c } generates options = { a:a, b:b, c:c, } I have a lot of maps in my app tha
by tiglionabbit 14y ago
Oh dude, just learned something new from this article.
options = {
a
b
c
}
generates
options = {
a:a,
b:b,
c:c,
}
I have a lot of maps in my app that look just like that. It'll save me a lot of repetition.
- j-kidd 14y agoMay I ask what are the use cases for maps like that? I don't think I have ever needed one myself.
- lowboy 14y agoI have situations like this quite frequently where I need to turn vars into members of an object: title = getTheTitle() img = (shouldWeGetImg) ? getImg() : "placeholder.jpg" body = ... # 8 lines of code to define body, some that reference title and img # this: obj = { title, img, body } # instead of: obj = {title: title, body: body, img: img}
- tiglionabbit 14y agoPretend there are newlines after a, b, and c. HTML ate my whitespace :P.