1var colors=["red","green","blue"];
2
3if(Array.isArray(colors)){
4 //colors is an array
5}
1Array.isArray([1, 2, 3]); // true
2Array.isArray({foo: 123}); // false
3Array.isArray('foobar'); // false
4Array.isArray(undefined); // false
5
1// I know javascript can be hard but see this example and you will learn
2
3// Javascript if condition and array example
4var people = ["filex", "alex", "jon"];
5var peopleNeeded = people[1]; // 1 is the index bc the index starts from 0
6
7if (peopleNeeded <= people[1]) {
8 console.log("alex needed");
9} else {
10 console.log("lol");
11}