I use TypeScript.
I want to get only the value of an object, but this error occurs: “TypeError
: Cannot read properties of undefined
(reading 'cd1
')”.
callList = {
cd1: "00001",
nm1: "17"
}
// cd = '17'
const getFindbyNm(cd) => {
const idx = callList.find(e => e.nm1 == cd)
console.log(idx['cd1']); // ← Error occuered.
}
What am I doing wrong?