Is there a name for an empty function?

If you have a feature like:

function FunctionT(){
//do something
}

Could you call it empty or undefined or either work? Is there an official name for this?

+4
source share
2 answers

A "noop" or "null function":

var noop = function(){}

In computer science, NOP or NOOP (short for No Operation) [...] a team that actually does nothing at all.

In computer science, a null function (or a null operator) is a subroutine that does not return data values ​​and leaves the program state unchanged

Sources, http://en.wikipedia.org/wiki/NOP , https://en.wikipedia.org/wiki/Null_function

+6
source

, " " - , , ( ); .


" " , , , , . ( , JavaScript , , , "-" .)

, , , , , .

" "

, , , - , --.

:

function doStuff(data, callback) {
   callback = callback || function(){};
   callback(compute(data));
}
+2

Source: https://habr.com/ru/post/1529629/


All Articles