filmov
tv
Easy JavaScript - Intro to Custom JavaScript Functions (27)

Показать описание
The next few tutorials will go over custom functions in JavaScript. We've used functions in the past in the Easy JavaScript series, and now it's time for a deeper dive.
A function is just a block of code designed to perform a particular task. Functions are also reusable. When you call a function, the proper term is invoking a function, and it can be invoked multiple times within the same script (or even from external scripts if a reference to the function definition exists).
Functions can be tied to buttons (which we saw in the onclick tutorial) and be used as methods in objects (something we will cover in another tutorial). They are delcared with the JavaScript reserved keyword named function followed by the name of the function. They can also be assigned to variables. And functions can either return values or just do a basic command and end.
Functions are normally found at the end of your script, or even a completely different file by referencing the file.
Parameters can be defined to receive values from another part of your script. The piece of code sending the parameter is called the argument.
I hope you enjoy the video and if you have any questions, please ask in the comments below. If you have any requests feel free to let me know. Thanks for watching and remember to subscribe!
-----------