O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Functions

We start with functions as that is the primary script code that JavaScript developers write. C# developers will notice that functions are not bound by namespaces or classes. Instead, they are just defined as script. You can then call these functions inside your page as a response to a user action or similar.

A JavaScript declarative function is code you write to execute an action and possibly return a value(s). Again, this should be familiar to server-side developers. Functions can be declared anywhere in your script, including as a method of a JavaScript object (more on this in a moment). You declare a function with the keyword function. You then name it, set any parameters inside parentheses, and use the return keyword to return a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required