DEV Community

Louis
Louis

Posted on

Notes on default ES behavior

const n = null

console.log(n?.something) // undefined

const o = {}

console.log(o?.something) // undefined

function test(d = 0) {
    console.log({ d })
}

test(o?.something) // { d : 0 }
test(n?.something) // { d : 0 }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)