Lit Aiy Lit Aiy - 1 year ago 198
Javascript Question

Get key from value with this node.js dictionary

I am using this node.js collection module.

I would like to get the key from value inside a dictionary. Here is my 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 the value from key is easy.
will return
. However, I am encountering problem in getting the key from value. Preferably, I would like to do something like
and have it return
. Any other methods are welcomed.

Answer Source

will you have more than one same values in the dict ? another possible methods could use map() function in collectionjs

mapDict = [];,k) { '
    if (v === "DATA_NOT") { 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download