A common problem when dealing with some kinds of data is that not every object has the same nested structure. luke_skywalker.parents.father.is_jedi works, but anakin_skywalker.parents.father.is_jedi throws an exception, because anakin_skywalker.parents.father is undefined. But we can reduce a path to provide safe default values and avoid exceptions when walking the same path on non-homogenous objects - watch to learn how! :)
Excellent series, I learned a lot. Looking forward to other series from you.
So enlightening! Thank you so much :)
This has been great, thanks!
Has any assignment or practice questions?
Wow! These series are packed with practical information yet very easy to follow. I finally get reduce 💡 You are an amazing teacher Mykola. Thanks!
Amazing series. I'm so surprised to keep learning about (what may appear) "simple" concepts!
Nowadays you can use optional chaining, which has an extra advantage of being type safe if you're using typescript, which it wouldn't if you're just splitting a string to get names of fields.
function fatherWasJedi(character) {
return character?.parents?.father?.jedi;
}