Appendix E. Function Declarations vs. Function Expressions

In JavaScript the two most common ways to define functions are by using function declarations and function expressions. A function declaration looks like this:

function myFunction(){}

...whereas a function expression looks like this:

var myFunction = function(){};

Throughout this book I have defined functions using function declarations rather than function expressions. I’ve done so because:

Image This is a book for beginners. Wherever there are two or more possible approaches to doing something in JavaScript, I’ve endeavored to present only the simplest approach so that beginners are not overwhelmed ...

Get A Beginner’s Guide to Writing Minecraft Plugins in JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.