Skip to content

Fix functions docs #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion concepts/functions/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ What this means in practice depends on the data type of the argument.

- For all other values (objects, arrays, functions) it is a mixed bag.
Since the reference is copied, a reassignment will not affect the original value.
However, since you care dealing with a [shallow copy][wikipedia-shalllow-copy], modifying the argument in the function body will also change the original value that was passed in.
However, since you are dealing with a [shallow copy][wikipedia-shalllow-copy], modifying the argument in the function body will also change the original value that was passed in.

By default, all parameters defined in the function declaration are optional in JavaScript.
If you provide less arguments than there are parameters, the missing arguments will be `undefined` inside the function, see [Null and Undefined][concept-null-undefined].
Expand Down
11 changes: 5 additions & 6 deletions concepts/functions/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ someName(arg1, arg2, arg3);

## Parameters

When working with parameters inside the function body, be aware of possible side effects to the original value that was passed to the function.
In JavaScript, the behavior depends on the data type of the argument.
When working with parameters inside the function body, be aware of possible side effects.

- All values that have [primitive data types][mdn-primitives] are immutable in JavaScript, so if used as arguments they are _passed by value_.
That means you are dealing with a copy of the original value in the function body and you can modify it without affecting the original value.
- All other values (objects, arrays, functions) are _passed by reference_.
If you modify arguments of non-primitive types, you are changing the original value outside of the function because the argument represents a reference to the original value, not a copy of that value.
- Values of [primitive data types][mdn-primitives] are _immutable_.
The original value is never affected by what happens to the argument in the function body.
- For all other values (objects, arrays, functions), a reassignment will not affect the original value.
However, if you modify such an argument (e.g. add a key to an object), that also modifies the original value that was passed in.

By default, all parameters defined in the function declaration are optional in JavaScript.
If you provide less arguments than there are parameters, the missing arguments will be `undefined` inside the function, see [Null and Undefined][concept-null-undefined].
Expand Down
11 changes: 5 additions & 6 deletions exercises/concept/lasagna-master/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ someName(arg1, arg2, arg3);

## Parameters

When working with parameters inside the function body, be aware of possible side effects to the original value that was passed to the function.
In JavaScript, the behavior depends on the data type of the argument.
When working with parameters inside the function body, be aware of possible side effects.

- All values that have [primitive data types][mdn-primitives] are immutable in JavaScript, so if used as arguments they are _passed by value_.
That means you are dealing with a copy of the original value in the function body and you can modify it without affecting the original value.
- All other values (objects, arrays, functions) are _passed by reference_.
If you modify arguments of non-primitive types, you are changing the original value outside of the function because the argument represents a reference to the original value, not a copy of that value.
- Values of [primitive data types][mdn-primitives] are _immutable_.
The original value is never affected by what happens to the argument in the function body.
- For all other values (objects, arrays, functions), a reassignment will not affect the original value.
However, if you modify such an argument (e.g. add a key to an object), that also modifies the original value that was passed in.

By default, all parameters defined in the function declaration are optional in JavaScript.
If you provide less arguments than there are parameters, the missing arguments will be `undefined` inside the function, see [Null and Undefined][concept-null-undefined].
Expand Down