js.l22 code example
Example: js.l22
Most Usable in Array:
---------------------
// console.log(arr);
// console.log(arr[1]);
// console.log(array.length);
// console.log(array.length-4);
// console.log(array[array.length-2]);
// colors.push('add_in_end');
// colors.unshift('add_in_start');
// colors.pop();
// colors.shift();
// console.log(colors.indexOf('red')); // array positioning
// console.log(colors.includes('blue')); // return true of false
............................................................................
----------------------------------------------------------------
Array propertices:
----------------------------------------------------------------
[ constructor ] // console.log(fruits.constructor); //Returns the function that created the Array object's prototype
[ length ] // console.log(array.length); // console.log(array[array.length-2]);
[ prototype ] // fruits.myUcase(); // Allows you to add properties and methods to an Array object
----------------------------------------------------------------
Array Methods:
-------------------------------------------------------------------
[ includes() ] // console.log(array.includes('blue')); // return true of false
[ concat() ] // array1.concat(array2, array3, ..., arrayX) // join two or more arrays.
[ indexOf() ] // console.log(colors.indexOf('red'));
[ join() ] // console.log(array.join()); // The join() method returns the array as a string.
[ lastIndexOf() ] // console.log(array.lastIndexOf()); //The lastIndexOf() method searches the array for the specified item, and returns its position.
[ pop() ] // colors.pop();
[ push() ] // colors.push('add_in_end');
[ reverse() ] // console.log(array.reverse()); //The reverse() method reverses the order of the elements in an array.
[ shift() ] // colors.shift();
[ slice() ] // console.log(fruits.slice(1, 4)); //The slice() method returns the selected elements in an array, as a new array object.
[ sort() ] // console.log(fruits.sort()); //Sorts the elements of an array
[ splice() ] // console.log(fruits.splice(1)); // console.log(fruits.splice(2 , 4)); // The splice() method adds/removes items to/from an array, and returns the removed item(s).
[ toString() ] // console.log(fruits.toString()); // returns a string with all the array values, separated by commas.
[ unshift() ] // colors.unshift('add_in_start');
[ valueOf() ] // console.log(fruits.valueOf()); // The valueOf() method returns the array.
[ ] //
[ ] //
[ ] //