kutyel/optics.js

Prisms should use null or undefined?

serras opened this issue · 2 comments

Right now prisms use null as the return value when something is not there. But should we use undefined instead? This would be coherent with what JS does with properties not available in objects.

const o = { milk: 6 }
const p = o['pie']  // undefined

I am opening the issue to track the discussion.

Right now I lean towards undefined for the reasons exposed above.

I think undefined is JS' fallback behaviour when things are not defined (duh) but if you want to signal absence of a value, you should definitely use null. 😉