define array jquery code example

Example 1: how to take create array using jquery

var length = 5;
var array = [];
var i = 0;

for (i = 0; i != length; i++){
  array.push(i)
  //array.push is used to push a value inside array
} 

console.log(array);

//console.log is used to check array value inside your console

Example 2: jquery create array

var colors = ['red','blue','green'];

/*// OUTPUT
---------------------------*/
console.log(colors[1]); // Outputs 'blue'

Example 3: javascript get array value

var array = []
array[0] = "hi"
array[1] = "dude"
var done = false
while (done == false){
var valueToFind = "hi";
  var rounds = array.length;
  if (rounds < 0){
  return false
  }
  if (array[rounds] == valueToFind){
  done = true
    return rounds
  }
  rounds = rounds - 1
}

Tags:

Php Example