In JavaScript, there isn’t technically a distinction between a function and a procedure. Both terms refer to blocks of code that are designed to perform a particular task.
However, in general programming terminology, there’s a slight difference between the two.
A function is a piece of code that takes input (parameters), performs some computation on them, and returns a result (output). Functions are expected to produce outputs and should always return a value.
On the other hand, a procedure performs a task but does not return a value. They’re typically used for their side effects, such as modifying the contents of a variable or altering the state of the program. They’re more about action than about producing a result.
In JavaScript, you might consider a function without a return statement to be a procedure. However, it’s worth noting that even without a return statement, JavaScript functions still return a value, implicitly returning undefined. So technically, there are no true “procedures” in Javascript.