Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the considerations for the use of return statements

Shulou Source: shulou.com Published: 2022-06-01 03:06:17 09月21日 Update

This article mainly explains "what are the matters needing attention in the use of return sentences". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the points for attention in the use of return statements?"

Precautions in using return statement

JavaScript ends automatically on the last line of code by default.

The following two instances return the same result (one with a semicolon and one without):

Example 1

Function myFunction (a) {

Var power = 10

Return a * power

}

Example 2

Function myFunction (a) {

Var power = 10

Return a * power

}

JavaScript can also use multiple lines to end a statement.

The following example returns the same result:

Example 3

Function myFunction (a) {

Var

Power = 10

Return a * power

}

However, the following instance result returns undefined:

Example 4

Function myFunction (a) {

Var

Power = 10

Return

A * power

}

At this point, I believe you have a deeper understanding of "what matters needing attention in the use of return statements". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Examples statements matters notes results content learning practical deeper same one line two code interest semicolon practicality practical simple operation method is in Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi Shulou Tech Info MariaDB Microsoft