Reputation: 3143
I'm not sure what kind of map functionality javascript/coffeescript has, but suppose I convert a Java map to an appropriate format, can i use coffeescript to do something like
thekey.getValue()
where getValue will be a function defined in my coffeescript that will do do the equivalent of
return MyMap.get(key) (returns value)
edit: I had a java tag because its not obvious to me depending on what I need to do how to convert the map from java to javascript
Edit: would something like this work?
click: ->
if Object1.label in Object2
$("#multiValueSelect").val(Object2[Object1.label].toLowerCase()).trigger "change"
else
$("#multiValueSelect").val(Object1.label.toLowerCase()).trigger "change"
Upvotes: 0
Views: 3177
Reputation: 6712
I think you can define a map and use it in javascript like
var map = {}; (or you give it appropriate value)
return map[key]; (or map.key)
in coffeescript:
map = {}
map[key] (or map.key)
Upvotes: 0
Reputation: 146084
JavaScript's fundamental Object
type is essentially a Map as it is. In both JavaScript and CoffeeScript myObject.value
will get you the property named value
out of myObject
. To get a property using a string key, use square brackets: myObject[key]
.
Upvotes: 1