Skip to content
Advertisement

combination of OPTIONAL CHAINING and NULLISH COALESCING operator not rendering the expected result

i am just learning about this combo of Optional chain and Nullish coalescing. Here is the object

JavaScript

as i am trying to check if the method exist,it is printing out both of them anyway.what am i doing wrong?

JavaScript

Advertisement

Answer

Perhaps return a value from the function otherwise it has an undefined value:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement