JavaScript Tutorial

The language for programming web pages.

JS Functions

JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task. A function is executed when something invokes (calls) it.

Function Types:

  • Function Declarationfunction name() {}
  • Function Expressionconst name = function() {}
  • Arrow Functionconst name = () => {}
  • IIFE — Immediately Invoked Function Expression
  • Callback — Function passed as argument

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics