Get the App
SLTechnology News&Howtos  ›  Development  › 

How to abbreviate implicit return value of JavaScript

Shulou Source: shulou.com Published: 2022-06-01 04:38:44 11月01日 Update

Editor to share with you how to abbreviate the implicit return value of JavaScript, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Implicit return value

The return value is the keyword that we usually use to return the final result of the function. The arrow function with only one statement can implicitly return the result (the function must omit parentheses ({}) in order to omit the return keyword).

To return a multiline statement, such as object text, you need to wrap the function body with () instead of {}. This ensures that the code evaluates as a single statement.

Function calcCircumference (diameter) {return Math.PI * diameter}

Abbreviated as:

CalcCircumference = diameter = > (Math.PI * diameter;) the above is all the content of the article "how to abbreviate the implicit return value of JavaScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Function abbreviation article statement key keyword content result not much code package single only most object form text more knowledge arrow Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux vpn macOS Microsoft Shulou Information