I have a simple associative array in Coffeescript
as follows
things =
login: 'login/'
search: 'search/'
custard: 'trampoline/'
and I want to generate an array ['login/', 'search/', 'trampoline/']
Sure I could do this:
thArr = []
for k, v of things
thArr.push v
but I'm sure there is a one-line way to do this, but I'm not sure how.
thArr = (v for k, v of things)
If you know what index the key => value are located at. eg
arr = {a: 1, b: 2, c: 3}
Object.values(arr)[0]
result: = 1 *because a: 1 is at index 0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.