DEV Community

Discussion on: The Difference Between Null and Undefined in JavaScript

Collapse
 
apyrkh profile image
Aliaksandr

What about

const bar = { foo: undefined }
bar.foo === undefined 

// and this
const bar = {}
bar.foo === undefined 
Enter fullscreen mode Exit fullscreen mode

This is not the same, right? Also in the latest typescript it was implemented to differentiate these 2 cases.

I prefer null for nullish values.