Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use the void keyword? [duplicate]

Tags:

People also ask

What is the purpose of keyword void in function?

When used as a function return type, the void keyword specifies that the function doesn't return a value. When used for a function's parameter list, void specifies that the function takes no parameters. When used in the declaration of a pointer, void specifies that the pointer is "universal."

What is the use of void keyword in JavaScript?

void is an important keyword in JavaScript which can be used as a unary operator that appears before its single operand, which may be of any type. This operator specifies an expression to be evaluated without returning a value. The operator evaluates a given expression and then returns undefined.

How do you return a void in JavaScript?

If inserting an expression into a web page results in an unwanted effect, then use JavaScript void to remove it. Adding “javaScript:void(0)”, returns the undefined primitive value. The void operator is used to evaluate the given expression. After that, it returns undefined.


I came across this snippet in kriskowal/q:

/**
 * Applies the promised function in a future turn.
 * @param object    promise or immediate reference for target function
 * @param args      array of application arguments
 */
Q.fapply = fapply;
function fapply(value, args) {
    return dispatch(value, "apply", [void 0, args]);
}

What is the point of using the void keyword? Why not just write [undefined, args]?