OneBite.Dev - Coding blog in a bite size

declare a void function without return value in Javascript

Code snippet on how to declare a void function without return value in Javascript

  function doSomething() {
    // code here
  }

This is a sample of code written in Javascript that declares a void function without a return value. A void function is a type of function in Javascript that does not return a value. In this example, the function is named ‘doSomething’. It is followed by a set of curly braces, which contain the code that will be executed when the function is called. Everything within the braces makes up the body of the function. If no return value is necessary, this code can be left empty. After the closing brace, the function has been declared and is now ready to be used in your code.

javascript