I have this object:
const cOPE= { ADD: 43
, SUB: 8722
, MUL: 261
, DIV: 247
, EQU: 61
, Point: 46
, Clear: 99
}
and I currently use:
const kOPE = k => Object.entries(cOPE).find(o=>o[1]==k)[0]
to retrieve a key value based on a value. example:
console.log( kOPE(261) ) // -> MUL
Is there a better way to code the kOPE
function?
Isn't there simply a JS function that can return the name of a key?
[+] this code is internal in a closed object, other values cannot exist and each key is unique.