Syntax:
function ( ) : like { }
See parameters for parameter syntax.
A function can optionally have type annotations which indicates the expected parameter types and return values:
function sum(a : Number, b : Number) : Number { return a + b; }While type annotations are always optional, it is especially recommended to add type annotations to function parameters.
If the function contains only a single expression, a simpler syntax without the curly brackets and explicit return can be used:
function ( ) : likeExample:
function add(a,b) a+b;is equivalent to
function add(a,b) { return a+b; }
See also: Getters and setters for functions that disguise as properties.
