
If you are a javascript developer then you definitely know about try-catch block which is used to deal with errors. But now you can use new Safe Assignment operator proposal (?=)
try-catch blocks lead to nested code making it harder to read and maintain.
?= operator reduces nesting and it gives result of function into tuple.
If an error occurs, it returns [error,null]otherwise it returns [null, result].
async function fetchData() { const [error, response] ?= await fetch("https://api.example.com/data"); if (error) return handleError(error); return response; }
The above is the detailed content of No need of Try-Catch!! Javascript introduced new safe assignment operator✌. For more information, please follow other related articles on the PHP Chinese website!
How to solve 504 gateway timeout
Excel table slash divided into two
The difference between win10 home version and professional version
Usage of RAC in Oracle
What are the regular expressions in php
Solid state drive data recovery
How to modify folder 777 permissions
What is the principle and mechanism of dubbo