Functions in JavaScript
Functions in Javascript We're about to deep dive into Functions in JavaScript and, as you'll see, this is where you start to see some major differences from Java. I know because they have a similar name and syntax, it's easy to assume that the two languages are the same, but JavaScript is a lot less rigid in its form, which is very apparent in how Functions are constructed. Let's get into it! Function Declarations Functions are what we would think of as methods in Java, a block of code that performs a task when called upon. We previously discussed how JavaScript doesn't require data types in variable declarations , and the same thing applies to functions . You don't have to specify the return type in the function's signature, nor do the parameters reference a data type. Function Declaration Syntax Declaring a function requires the "function" keyword, a name, the parameter(s), the keyword "return" and a return statement. ...