5/19/2023 0 Comments Javascript questionmark operatorThere is an object obj whose value is a person, where person is another object and has a property name with value studytonight. In the given code, there is a nested object (object inside the object). Let's understand it with the help of some examples. Here is the syntax for using optional chaining operator, obj.val?.prop It is written with a question mark and a colon. So here what I could say is, has permission and then Im going to do a question mark, and then well say active and Im making all of this up right here. Instead of returning an object, it will return either null or undefined. The last logical operator I will discuss is not unary, not binary, but ternary, operating on three values. ) operator accesses an objects property or calls a function. Optional chaining is nothing but a syntax with the help of which we can access deeply nested properties in a Javascript object without checking whether that property exists or not. JavaScript MDN Optional chaining (.) The optional chaining (. The new Javascript Optional Chaining operator is introduced in ECMAScript 2020 also known as ES11 or ES 2020.
0 Comments
Leave a Reply. |