typescript function return array 1

typescript function return array

function retarray():string[] { 
   return new Array("Apple","Grappe","Banana");
var fruits:string[] = retarray();

Here is what the above code is Doing:
1. The retarray() function returns an array of strings.
2. The fruits variable is assigned the return value of the retarray() function.
3. The fruits variable is declared as an array of strings.

The following example shows how to pass an array as a function parameter.

Similar Posts