More Array Methods
How do I make an more array methods?
What is a more array methods? How do you make a more array methods? This script and codes were developed by Martin Baillie on 25 January 2023, Wednesday.
More Array Methods - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>More Array Methods</title>
</head>
<body> <script src="js/index.js"></script>
</body>
</html>
More Array Methods - Script Codes JS Codes
'use strict';
/*
Array.isArray(obj)
var new_arr = arr.concat(value1[, value2[, ...[, valueN]]])
var boolean = arr.every(function(currentValue[, index[, array])[, thisArg])
var arr = arr.fill(value[, start = 0[, end = this.length]])
var new_arr = arr.filter(function(element[, index[, array])[, thisArg])
var value || undefined = arr.find(function(element[, index[, array])[, thisArg])
*/
var cl = console.log;
console.clear();
var a = [1,2,3,4,5];
var b;
var c;
var d;
var obj = {};
cl('a.length', a.length);
cl('b = a.slice() new arr', b = a.slice());
cl('b', b);
cl('a', a)
cl('a.pop() el removed', a.pop())
cl('a', a);
cl('b', b)
cl('a.push(el,..) length', a.push(5,6));
cl('a', a);
cl('a.shift() el removed', a.shift())
cl('a', a)
cl('a.unshift(el,..) length', a.unshift(1));
cl('a', a);
cl('a.forEach(function (item, index, array) { ... }, thisArg) returns undefined', a.forEach(function (item, index, array) { this['index' + index] = item; }, obj)
);
cl('Result of forEach()', obj);
cl('a.find(function (item, index, array) { ... }, thisArg) returns item', a.find( function ( item, index, array) { return item === 3; }, obj)
);
cl('a.every(function ( item, index, array) { ... }, thisArg) returns boolean', a.every(function (item, index, array) { return item < 10; }, obj)
);
cl('a.filter(function ( item, index, array) { ... }, thisArg) returns array', a.filter(function(item, index, array) { return item >= 3; }, obj)
);
cl('a.findIndex(function ( item, index, array ) { ... }, thisArg) returns index', a.findIndex(function(item, index, array) { return item === 3; }, obj)
);
d = [1,4,9];
cl('a.map(function ( item, index, array ) { ... }, thisArg) returns new array', d.map(Math.sqrt), d.map(function( item, index, array ) { return item * 2; }, obj ), d
);
c = [3,2,1,5,4];
cl('a.sort([function(a,b)]) returns new array (modifies array)', c.sort(function(x,y) { return x - y}), // callback function required for numbers c.sort( (x, y ) => x - y ), c
);
cl('a.reduce(function( previousValue, currentValue, currentIndex, array } { ... }, initialValue) returns reduction value)', a.reduce( function (previousValue, currentValue, currentIndex, array ) { return previousValue - currentValue; }), a.reduce( (prev, curr, i, arr) => prev - curr)
);
cl('a.reduceRight(function( previousValue, currentValue, currentIndex, array } { ... }, initialValue) returns reduction value)', a.reduceRight( function (previousValue, currentValue, currentIndex, array ) { return previousValue - currentValue; }), a.reduceRight( (prev, curr, i, arr) => prev - curr)
);
cl('a.reverse() returns new array (modifies array)', a.reverse());
cl('a.toString() returns comma separated string', a.toString());
cl('a.join(separator = \',\') returns string', a.join(), a.join('|'), a.join(', '), a.join('')
);
cl('a.indexOf(el[, fromIndex]) index || -1', a.indexOf(2, 2));
cl('a.lastIndexOf(searchElement[, fromIndex = arr.length - 1]) returns index || -1', a.lastIndexOf(5, a.length-2)
);
cl('a.includes(searchElement[, fromIndex]) returns boolean', a.includes(5,1)
);
b = a.slice();
cl('a.splice(start, deleteCount[, item1[, item2[, ...]]]) returns deleted elements (modifies array)', b.splice(0, 2, 8, 9), b
);
cl('a.fill(value[, start = 0[, end = this.length]]) returns modified array (modifies array)', a.fill(5, 1, a.length - 1), Array(3).fill(4)
);

Developer | Martin Baillie |
Username | martin42 |
Uploaded | January 25, 2023 |
Rating | 3 |
Size | 2,327 Kb |
Views | 2,023 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Shuffle List Animation | 2,362 Kb |
Forms testing | 2,272 Kb |
JS Interview Questions | 7,121 Kb |
A Pen by Martin Baillie | 2,210 Kb |
Draughts | 6,273 Kb |
Shortest Path | 2,661 Kb |
M-test | 1,250 Kb |
URL Compare | 2,519 Kb |
More interview Questions | 5,531 Kb |
Sticky Header | 1,911 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
The Fly | GianlucaGuarini | 3,405 Kb |
UI Challenge - Budget Selector | AgentRR007 | 3,547 Kb |
Transition | Shayhowe | 1,632 Kb |
Flexbox playground | Enxaneta | 5,418 Kb |
FreeCodeCamp - Simon Game | Ivhed | 8,481 Kb |
Classy Blockquote Styling | Andrewwright | 3,212 Kb |
Count checked checkboxes with jQuery | Mestika | 2,343 Kb |
CMP5-Opdracht15 | SannevanGastel | 2,733 Kb |
CSS3 Snow Animation | NickyCDK | 1,695 Kb |
Snow collision | Wojtek1150 | 3,542 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!