JavaScript Optional Chaining in 5 Minutes (No more 'cannot read property of undefined'!)

preview_player
Показать описание
Save yourself some JavaScript code by using Optional Chaining. Optional Chaining can help you help work with data that might be inside of nested objects. You longer have to check that each object "along the chain" exists. This means no more "cannot read property x of undefined"....YAY!

_____________________________________________

Newsletter 🗞
Interested in exclusive content and discounts? 🤯 Sign up for the newsletter!
_____________________________________________

Connect with me 😀
_____________________________________________

COURSES 💻
Рекомендации по теме
Комментарии
Автор

You are life saver i looked for something like this so many times and never found it

Icemourne_
Автор

How? How do you still not have 100k subs? How? Just love the quality Javascript videos you put out!

pexeixv
Автор

I was wondering when you’ll be talking about this topic. Thanks for bringing this up 👏🏻

shashanksalunkhe
Автор

I knew about this. But did not know the other use cases. Thank you!

nitinravi
Автор

So glad that is part of the spec now! or at least can be complied now. Seemed so alien coming from laravel/php where you can just do Onwards and upwards with the Developer experience!

penry
Автор

Another way to make the code even prettier (according to me) is to use Short Circuit Conditionals. E.g. in your sendWelcomeLettersIfConfirmed function, you could just write:

student.address?.confirmed && console.log(...)

As I said, I find this prettier (and cleaner), but it's all relative to your coding style and/or your team's style guidelines.

MislimiRamo
Автор

I have been using javascript for 4 years now, did not know about this.

alinagy
Автор

been using this for a long time.Makes life a lot easier

mdridoy-efpw
Автор

I saw a short-circuiting evaluation example in MDN. Can I say, optional chaining operator, a short-circuit operator?

damo
Автор

Hey what vs code theme is this, i love it ! (btw slytherin >>)

zenitzo
Автор

What is different between? And ?? Mark

manojsatwase
Автор

Optional chaining is breaking when i save .js file in vscode..how to fix it?

hari
Автор

Hi James, I found your channel very recently and I think it's pretty useful. As a suggestion, I reckon a video about promises and async/await could be cool. Anyway, thank you for your content. Cheers.

jmartinez
Автор

Thanks for the amazing content as always
Just wanted to ask about the awesome font?

MominBinShahid
Автор

How do you populate an object? For instance with a form or other means. I have only seen objects hard coded. Populating arrays is easy, but Objects?

Knards
Автор

Can you also please about Nullish coalescing operator (??) pleeease thank you :)

donmikkodanm.olmillo
Автор

I am having problem in HTML . My Image is not showing in browser (Firefox) when html file is opened through live server extension (VS code).It throws a Security error that html file can't link to image. I want to use image as background.
My html file is folder in D: drive.

Path = D:/myhtml/index.html
And my image is in F: drive

Path = F:/mountain.png
my img tag is

```<img src="f:/mountain.png" alt="mountain"/>```
But when I open html file directly from file explorer image shows up.
Please help to solve this problem.

sparklite
Автор

Hello I'm new to your channel, I'm facing this error for days now

Uncaught TypeError: Cannot read properties of null (reading 'classList')

cyberlord
Автор

What do you use to search/as your clip board ?

sneddonisaac
Автор

May I know what is the intelligence that you are using to show computed hint?

jonathanwang