JavaScript Tutorial - How exactly Functions with return and global Variables works

Published: 01 January 1970
on channel: Programming for Everybody
169
3

JavaScript Tutorial - How exactly Functions with return and global Variables works
----------------------------------------------------------------------------------------------------------------------
Hello, today we will see, how functions work, in which command return is.

We have defined the function increaseValue, which increases the variable A by the value 2 and at the same time returns the variable A with the command return.

In the next step, we define that the value of the variable B should be equal to the value that the function increaseValue returns.

The question arises as to what the value of variable A will now be, and the answer is that as soon as we call the function increaseValue, this function returns the value of variable A to variable B, but before the return statement this function also increases variable A by 2.

Variable A thus will have a value 2 now and the same value will have variable B, in which this value function increaseValue returns.

We can now start the page and see that both variables have a value of 2.

Thank you for watching this video and if you like, subscribe to this channel and put like.


On this page of the site you can watch the video online JavaScript Tutorial - How exactly Functions with return and global Variables works with a duration of hours minute second in good quality, which was uploaded by the user Programming for Everybody 01 January 1970, share the link with friends and acquaintances, this video has already been watched 169 times on youtube and it was liked by 3 viewers. Enjoy your viewing!