Skip to content
This repository has been archived by the owner on Apr 1, 2021. It is now read-only.

Add JS Article Return #1195

Merged
2 commits merged into from
Jun 29, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions JS-Return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# JavaScript Return

## Introduction

When a **return** statement is called in a function, the execution of this function is stopped. If specified, a given value is returned to the function caller. If the expression is omitted, `undefined` is returned instead.

```javascript
return [[expression]];
```

[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return) | [MSDN link](https://msdn.microsoft.com/en-us/library/22a685h9.aspx)

## Examples

The following function returns the square of its argument, **x**, where **x** is a number.

```javascript
function square(x) {
return x * x;
}
```

The following function returns the product of its arguments, **arg1** and **arg2**.

```javascript
function myfunction(arg1, arg2){
var r;
r = arg1 * arg2;
return(r);
}
```
Copy link

@ghost ghost Jun 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add repl snippet 🚀