TypeScript: Undefined vs null - Stop using null (even in JavaScript)

preview_player
Показать описание
You barely need to use null in TypeScript. Instead, use solely undefined. In this episode on the series to learn about TypeScript I will explain a couple of reasons.

📖Chapters
0:00 Introduction
0:40 Undefined better than null
1:00 TypeScript Optional Parameter
1:45 TypeScript Triple Equals
3:05 Null and undefined typeof
3:30 TypeScript Desctruction Difference with null and undefined
4:30 State Tracking Alternative
6:15 Conclusion

📝Source Code

💬Social Networks

📚My Books & Courses
Рекомендации по теме
Комментарии
Автор

Thanks for somewhat clearing up some of my confusion. I'd been switching back and forth between making my values nullable and undefinable.

merklegroot
Автор

I don't think you need to convert everything (for example from a library) to undefined. You can check for null and undefined at once like this: "variable == null". Also, for your types, you can just create an Option type:
"type Option<T> = T | undefined | null;"
What do you think about this?

igorswies
Автор

Thx for the conten! But I wish the audio quality to be better. It sounds quite choppy to me.

wilsonwg