Posts

Showing posts from November, 2019

Optional Chaining & Nullish Coalescing in Javascript!!

Image
Javascript soon be having most awaited operators Optional Chaining & Nullish Coalescing . Currently these two features are as proposals in v8 ( optional-chaining , nullish-coalescing ). These operators are already available to try on chrome canary. It means we are seeing them soon in the chrome'a stable release and Node.js. For example lets define a book object Now if we want to access the sale property then it might be error-prone, as any of them might evaluate to null or undefined (also known as “nullish” values). To safely access the sale property, Checking for property existence on each step easily turns into a deeply-nested structure of if-statements or a long if-condition replicating the property access chain. or According to a recent spec proposal, “an optional chain is a chain of one or more property accesses and function calls, the first of which begins with the token ?.” Using the new optional chainin