Colon after function declaration in javascript [duplicate]

That’s a type declaration. :boolean means basically, that the isStringStart function must return a boolean value. The same with the argument’s type declaration. chr: number means, that the function accepts one argument, which has to be typeof number.

If the requirements are not fulfilled (not proper arguments are passed or wrong value is being returned), the typechecking library you are using will throw an error.

Leave a Comment