While the end result may often prove the same, there is an important difference between writing a function as a declaration and as an expression. In this video, Jeremy McPeak will teach you how to make your functions available at any time using “hoisting,” or function declaration, and offers his take on best practices. Beginner and intermediate web developers will learn how the JavaScript engine loads function declarations and expressions differently, and how this affects their code.

Take your JavaScript skills to the next level with Learning Paths in Safari.


Jeremy McPeak is a self-taught programmer who began his career tinkering with websites in 1998. He is the author of Beginning JavaScript, 5th Edition, JavaScript 24-Hour Trainer, and co-author of Professional Ajax, 2nd Edition. He also contributes to Tuts+ Code, providing articles, video tutorials, and courses on JavaScript, C#, ASP.NET, and PHP. He is currently employed by an oil and gas company, building in-house conventional and web applications.

Article image: Screenshot from "What is the difference between var functionName = function() {} and function functionName() {}?"