Colon after function declaration in javascript
1 answer
This is a type declaration. :boolean
means that the function isStringStart
should return a value boolean
. It's the same with the argument type declaration. chr: number
means that the function takes one argument, which must be typeof number.
If the requirements are not met (no valid arguments are passed or the wrong value is returned), the type checking library you are using will throw an error.
+3
source to share