Javascript method signature that doesn't return anything

#1

In javascript method signature, If we wanted to write javascript function that doesn’t return anything, what is return type? what is void equivalent?

0 Likes

#2

You can return nothing by not typing anything as a returned object/variable.
ex: member function(): js server

0 Likes

#3

If you include a : after function(), the parser expects there to be a return type. So the above example will fail with error: `E no viable alternative at input ‘js server’``.

Here’s a comparison of two valid fields:

funcA: function() js server
funcB: function() : int js server

where funcA does not have a return type, and funcB returns an integer.

0 Likes