Spread the Map's .key()
iterator to get an array of keys (hrefs), and then use Array.find()
to find an item that includes the string.
const fn = (hashMap, str) => [...hashMap.keys()].find(k => k.includes(str))
const hrefMap = new Map([["www.hello.com/12345",{"value":1,"color":"red"}],["www.hello.com/0000",{"value":2,"color":"blue"}]])
const result = fn(hrefMap, '12345')
console.log(result)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…