Lastor
1 weeks ago
[Coding] 邊看這篇文章,我腦中就浮現了一行 code......
type SuperNull = undefined | null
https://medium.com/...
Responses disabled for others than plurk poster
latest #7
Lastor
1 weeks ago
這又讓我想起之前遇到個白癡,我 call 一個 API function,那個 function 就是會回傳 undefined or 其他值,undefined 在那業務場景有特殊意義
Lastor
1 weeks ago
所以我需要判斷他是不是 undefined 然後做某些事
if status === undefined
Lastor
1 weeks ago
然後他 code review 給我提 issue 說,寫 JS 不應該出現 undefined
立即下載
Lastor
1 weeks ago
我就問他,那不然這不寫 undefined 你要怎麼判斷他是不是 undefined?
Lastor
1 weeks ago
我也試著換個角度跟他說,undefined 在 JS 裡面的意義,這個場景業務邏輯就是要判斷初始化了沒,用 undefined 在語意上也是合理的
Lastor
1 weeks ago
他說他不管,總之寫 undefined 就是錯誤行為
Lastor
1 weeks ago
後來沒多久他被公司 fire 了,其實我心裡挺爽的
back to top