return an array in javascript code example

Example 1: return array javascript

function func() {
  return [5, "string", {a: 7}];
}

Example 2: what are the two ways to create an array in javascript examples?

let scores = new Array(9,10,8,7,6);

Example 3: js fucntion return array

function BlockID() {
    var IDs = new Array();
        images['s'] = "Images/Block_01.png";
        images['g'] = "Images/Block_02.png";
        images['C'] = "Images/Block_03.png";
        images['d'] = "Images/Block_04.png";
    return IDs;
}

Tags:

Java Example