jquery - Get value from dictionary in JavaScript by key -
in javascript
script have created following dictionary.
var dictionary =[]; $(function () { dictionary.push({ key: @item.key.toshortdatestring().tostring(), value: @html.raw(jsonconvert.serializeobject(item.value)), }); alert(dictionary['2017-09-19']); });
in alert shows me undefined
. how can read value dictionary?
rather using array use object
$(function () { var dictionary = {}; dictionary[@item.key.toshortdatestring().tostring()] = @html.raw(jsonconvert.serializeobject(item.value)); alert(dictionary['2017-09-19']); });
Comments
Post a Comment