How to Create a Noop Function in JavaScript?

Creating a noop function in JavaScript

A "noop" (no-op, or NOP) is a "no-operation" function, which does nothing. You can create a noop function in JavaScript using either, a function declaration or a function expression, like so:

// function declaration/statement
function noop() {}
// function expression
const noop = function () {};

The same code can be written in a shorter syntax using the arrow function (introduced in ES6), for example, like so:

// ES6+
// function expression
const noop = () => {};

Hope you found this post useful. It was published (and was last revised ). Please show your love and support by sharing this post.