chaining.js 258 Bytes RawBlameHistoryPermalink 1 2 3 4 5 6 7 8 9 export const optionalChaining = (obj, ...rest) => { return rest.reduce((newObj, key) => newObj?.[key], obj) // let tmp = obj // for (const key in rest) { // const name = rest[key] // tmp = tmp?.[name] // } // return tmp || '' }