I am going through source code of Vue.js. In almost all the function declarations I find a new way of defining functions
function isStringStart (chr: number): boolean {
return chr === 0x22 || chr === 0x27
}
Can somebody explain me what is this kind of function declaration called?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With