A programming language is said to have first-class functions if it supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data strucures.

JavaScript treats functions as first-class citizens. What this means is that functions in JavaScript are treated as objects. They have the type Object, they can be assigned as the value of a variable, and they can be passed and returned just like any other reference variable.

let handleClick = function() {
    console.log('button clicked');
}

document.getElementById('fooButton').addEventListener('click', handleClick);

References