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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -