From the course: JavaScript Essential Training

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Functions and methods

Functions and methods

- [Narrator] So far in the course, we've mainly looked at data and how to handle it through objects and variables and arrays. But the main use of JavaScript is as a scripting language, meaning we use it to write programs. And that's what functions are for. A word of note here. The term function is typically used to refer to as a function that sits on itself whereas a method is a function that sits inside an object and acts on that object. They're effectively the same thing, they just appear in different contexts. Okay, a function can be created in a couple of different ways and how we create a function has an impact on how it can be used. The classic function is a function declaration and it looks like what you see here. We start with a keyword function, then we give the function a name, we pass parameters inside a parenthesis and this can either be nothing. So it can be just the parenthesis or it can have…

Contents