[removed] Quickly lookup value in object (like we can with properties)

后端 未结 4 542
名媛妹妹
名媛妹妹 2021-01-05 14:07

I have an object that has pairs of replacement values used for simple encoding / decoding (not for security, just for a convenience; too complicated to explain it all here).

4条回答
  •  爱一瞬间的悲伤
    2021-01-05 14:32

    You can create a reversed version of the mapping programmatically (instead of by hand) and use it instead.

    var rev = {}
    for (key in obj)
        rev[obj[key]] = key
    

提交回复
热议问题