1concat(arr1,[...]) // Joins two or more arrays, and returns a copy of the joined arrays
2copyWithin(target,[start],[end]) // Copies array elements within the array, to and from specified positions
3entries() // Returns a key/value pair Array Iteration Object
4every(function(currentval,[index],[arr]),[thisVal]) // Checks if every element in an array pass a test
5fill(val,[start],[end]) // Fill the elements in an array with a static value
6filter(function(currentval,[index],[arr]),[thisVal]) // Creates a new array with every element in an array that pass a test
7find(function(currentval,[index],[arr]),[thisVal]) // Returns the value of the first element in an array that pass a test
8findIndex(function(currentval,[index],[arr]),[thisVal]) // Returns the index of the first element in an array that pass a test
9forEach(function(currentval,[index],[arr]),[thisVal]) // Calls a function for each array element
10from(obj,[mapFunc],[thisVal]) // Creates an array from an object
11includes(element,[start]) // Check if an array contains the specified element
12indexOf(element,[start]) // Search the array for an element and returns its position
13isArray(obj) // Checks whether an object is an array
14join([seperator]) // Joins all elements of an array into a string
15keys() // Returns a Array Iteration Object, containing the keys of the original array
16lastIndexOf(element,[start]) // Search the array for an element, starting at the end, and returns its position
17map(function(currentval,[index],[arr]),[thisVal]) // Creates a new array with the result of calling a function for each array element
18pop() // Removes the last element of an array, and returns that element
19push(item1,[...]) // Adds new elements to the end of an array, and returns the new length
20reduce(function(total,currentval,[index],[arr]),[initVal]) // Reduce the values of an array to a single value (going left-to-right)
21reduceRight(function(total,currentval,[index],[arr]),[initVal]) // Reduce the values of an array to a single value (going right-to-left)
22reverse() // Reverses the order of the elements in an array
23shift() // Removes the first element of an array, and returns that element
24slice([start],[end]) // Selects a part of an array, and returns the new array
25some(function(currentval,[index],[arr]),[thisVal]) // Checks if any of the elements in an array pass a test
26sort([compareFunc]) // Sorts the elements of an array
27splice(index,[quantity],[item1,...]) // Adds/Removes elements from an array
28toString() // Converts an array to a string, and returns the result
29unshift(item1,...) // Adds new elements to the beginning of an array, and returns the new length
30valueOf() // Returns the primitive value of an array
1dogs.toString(); // convert to string: results "Bulldog,Beagle,Labrador"
2dogs.join(" * "); // join: "Bulldog * Beagle * Labrador"
3dogs.pop(); // remove last element
4dogs.push("Chihuahua"); // add new element to the end
5dogs[dogs.length] = "Chihuahua"; // the same as push
6dogs.shift(); // remove first element
7dogs.unshift("Chihuahua"); // add new element to the beginning
8delete dogs[0]; // change element to undefined (not recommended)
9dogs.splice(2, 0, "Pug", "Boxer"); // add elements (where, how many to remove, element list)
10var animals = dogs.concat(cats,birds); // join two arrays (dogs followed by cats and birds)
11dogs.slice(1,4); // elements from [1] to [4-1]
12dogs.sort(); // sort string alphabetically
13dogs.reverse(); // sort string in descending order
14x.sort(function(a, b){return a - b}); // numeric sort
15x.sort(function(a, b){return b - a}); // numeric descending sort
16highest = x[0]; // first item in sorted array is the lowest (or highest) value
17x.sort(function(a, b){return 0.5 - Math.random()}); // random order sort
18
1<script>
2 // Defining function to get unique values from an array
3 function getUnique(array){
4 var uniqueArray = [];
5
6 // Loop through array values
7 for(var value of array){
8 if(uniqueArray.indexOf(value) === -1){
9 uniqueArray.push(value);
10 }
11 }
12 return uniqueArray;
13 }
14
15 var names = ["John", "Peter", "Clark", "Harry", "John", "Alice"];
16 var uniqueNames = getUnique(names);
17 console.log(uniqueNames); // Prints: ["John", "Peter", "Clark", "Harry", "Alice"]
18</script>
1let a = ['sam','john','ali','kahn'];
2let b = [19,23,41,61];
3let p = 'var val';
4
5// #### arrays all type to declera
6
7 let a = [34,'osama',929,'ali','kahn']; //1st to declar arry
8 let a = new Array(); //when you dont know mant is their
9
10let mlutiarry = [
11 ['osama','khan','ali'], //array in array
12 [12,45,34],
13 ['audit','val','naztown']
14];
15
16// #### arrays all type to declera
17
18 let r = Array.isArray(b); //check is arry or not
19 let c = a.includes("ali"); //check wether value is in arry or not (its case sensetive)
20
21 a.sort(); //sort all value
22 a.reverse(); //reverse all value
23
24 let st = a.toString(); //array into string
25 let st = a.join("-"); // same but without ,
26 let n = a.concat(b); //join two make one arry
27
28 a.pop(); //delete end val in array
29 a.shift(); //delete start val in arry
30
31 a.push("new"); // add new val to end
32 a.unshift("new"); //add new val to start
33
34 a[2] = "ali new"; //add modify/update value frome array any where you want
35 delete a[0]; //delete value frome array any where you want but still undefine
36
37 let n = a.slice(1,3); //slice new arry for exiting array;
38 a.splice(2,0,"osama"); //splice used to add new items to an array:
39
40 let i = a.indexOf("ali"); //give first indexof vale
41 let i = b.lastIndexOf(19); //gae last indexof vale
42
43 let res = b.some(function(age) { //if some is match retrun true
44 return age >= 18;
45})
46let res = b.every(function(age) { //if every is macth return true
47 return age >= 18;
48})
49
50let res = b.find(function (age) { //return first value
51 return age >= 29;
52})
53
54let res = b.findIndex(function (age) { //return first value indexs
55 return age >= 20;
56})
57
58let ar = [
59 {name:"lola",age: 23},
60 {name:"loki",age: 63},
61 {name:"ka",age: 43}
62];
63let r = ar.map(function (v) { // use to make new array
64 return document.write(v.name + "bathroom m");
65})
66document.write(res + "<br");
67
68
69
70
71
72let s = "this is an strig methods";
73let s2 = "yeh i use to it";
74let s3 = "this is end of it";
75
76
77
78 let r = s.length; //use to get length with space
79
80 let r = s.toUpperCase(); //upper all words
81 let r = s.toLowerCase(); //lower all words
82
83 let r = s.includes("an"); //return true if he find (casesensetive)
84 let r = s.startsWith("th");// return true if he find fist-word (casesen..)
85 let r = s.endsWith("ds"); //retrun true if the find last-word (cseseen..)
86
87 let r = s.search("strig"); //return index if he find (cases...)
88
89 let r = s.match(/is/g); //make new array with all same words
90
91 let r = s.indexOf("is"); //return index of first world only (casesen...)
92 let r = s.lastIndexOf("is"); //return index of last world only (casee...)
93
94 let r = s.replace("methods","function"); // replace the first value only
95
96 let r = s.trim();// trim form left to right
97
98 let r = s.charAt(5); //retrun char on string
99 let r = s.charCodeAt(5); //return unicode of char
100 let r = String.fromCharCode(65); // put unicode and return char
101
102 let r = s.concat(s2,s3); //join two string together
103
104 let r = s.split(" "); //split string and make new array
105
106 let r = s.repeat(3); //repeat same string as mush as you want
107
108 let r = s.slice(3,20); //return new string where ever you want
109// let r = s.substr(start,how many);
110// let r = s. substring(start,how many - 1);
111document.write(r);
112
113// this is an number methods
114
115let n = 9.4356775;
116
117
118// let r = Number(n); //convert string into number
119
120// let r = parseInt(n); //convert decimal into int
121// let r = parseFloat(n); //return with decimal num if he is
122
123// let r = Number.isFinite(n); // return true int
124// let r = Number.isInteger(n); return true only on int
125
126// let r = n.toFixed(2); // return int with decimal as many as you want
127// let r = n.toPrecision(4); // return int with decimal as many as you want +1 last decimal
128document.write(r);