javascript - Get key from value with this node.js dictionary -
i using node.js collection module. http://www.collectionsjs.com/
i key value inside dictionary. here code;
"use strict"; var dict = require("collections/dict"); var data_type = new dict( { "00": "data_not", "01": "data_sensor", "02": "data_sensor2", "03": "data_sensor3", });
getting value key easy. data_type.get("00");
return data_not
. however, encountering problem in getting key value. preferably, data_type.getkey("data_not");
, have return "00"
. other methods welcomed.
will have more 1 same values in dict ? possible methods use map()
function in collectionjs
mapdict = []; dict.map(function(v,k) { ' if (v === "data_not") { mapdict.add(v,k); } }); mapdict.get(0);
Comments
Post a Comment