Data types in ECMA5 or JS :
stringnumberbooleannull/undefined – to specify empty of nothingObject – to specify everything else in JSany – it is not used manually mostly but inferred by js to those whose type are dynamicaaly defined, the true nature of JS.
function overloading:
function can be overloaded(same name different signature) in javascript the the implementation is one,other function declaration appears above the implemented one, and the implementation one is always called.
Example:
function overload(x:string,y:string)
function overload(x:any[],y: any[])
function overload(x:(string|any[]),y:(string|any[])){ //here x,y is string or array of any type(number/string)
var len: number=x.length+y.length;
return len;
}
Declaring type for function parameter & normal variable type:
syntax for variable-
variable_name: type;
example-
name: string;
explanation -
type is declared after colon sign(:) after the variable name.
Syntax for function-
function myfunction(x: string,y: number): any{
}
description:
function takes two parameter of types – string & number and return type is any (can be anything -inferred dynamically not recommended but just for example).