JavaScript

Wat zijn functies en arrow functions?

Functies zijn reusable blocks code.

Home/Categorieën/JavaScript/Wat zijn functies en arrow functions?

Function declaration vs expression

Declaration: function greet() { ... } - hoisted Expression: const greet = function() { ... } - niet hoisted Arrow: const greet = () => { ... } - moderne syntax

Arrow function nuances

Arrow syntax: (args) => { return value; } Short arrow (implicit return): (x) => x * 2 No arguments binding No own 'this' (inherits from parent scope)

Code Voorbeelden

JAVASCRIPTFuncties✏️ Interactief
✏️CODE AANPASSEN
LIVE PREVIEW

Relevante trefwoorden

functionarrow functionparameters