From the course: Learning the JavaScript Language

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Basic functions

Basic functions

- [Instructor] In this video, we're going to begin looking at functions, which are a way of packaging up lines of code in one unit that you can name, invoke, and maintain separately. We've been dancing around the idea of functions a bit in this course. It's kind of difficult to talk about anything in JavaScript that's meaningful without touching on functions on some level. So I'm glad we're getting to it properly now. Anytime I've talked about methods that are part of objects, those have been functions. And now it's time to talk about making our own. We're going to start out with these four lines of code. Just four lines of logging messages to the console with animal noises, not rocket science, but just bear with me. I'm going to grab these out of the file, copy them, and I'm going to open a browser tab, and open up a JavaScript console. If I'm going to print these animal noises repeatedly, it's easy enough. I can…

Contents