Premium Only Content

JavaScript Array Functions (#shorts)
Hi Friends,
JavaScript Array Functions
JavaScript provides many useful built-in functions for working with arrays. Here are some examples of commonly used array functions:
push(): adds one or more elements to the end of an array.
let fruits = ['apple', 'banana'];
fruits.push('orange', 'pear');
console.log(fruits); // ["apple", "banana", "orange", "pear"]
pop(): removes the last element from an array and returns it.
let fruits = ['apple', 'banana', 'orange'];
let lastFruit = fruits.pop();
console.log(lastFruit); // "orange"
console.log(fruits); // ["apple", "banana"]
shift(): removes the first element from an array and returns it.
let fruits = ['apple', 'banana', 'orange'];
let firstFruit = fruits.shift();
console.log(firstFruit); // "apple"
console.log(fruits); // ["banana", "orange"]
unshift(): adds one or more elements to the beginning of an array.
let fruits = ['apple', 'banana'];
fruits.unshift('orange', 'pear');
console.log(fruits); // ["orange", "pear", "apple", "banana"]
slice(): returns a new array containing a portion of the original array.
let fruits = ['apple', 'banana', 'orange', 'pear'];
let citrus = fruits.slice(2);
console.log(citrus); // ["orange", "pear"]
splice(): changes the contents of an array by removing or replacing existing elements and/or adding new elements.
let fruits = ['apple', 'banana', 'orange', 'pear'];
fruits.splice(1, 2, 'grape', 'melon');
console.log(fruits); // ["apple", "grape", "melon", "pear"]
concat(): merges two or more arrays and returns a new array.
let fruits = ['apple', 'banana'];
let moreFruits = ['orange', 'pear'];
let allFruits = fruits.concat(moreFruits);
console.log(allFruits); // ["apple", "banana", "orange", "pear"]
indexOf(): returns the index of the first occurrence of a specified value in an array, or -1 if it is not found.
let fruits = ['apple', 'banana', 'orange'];
let orangeIndex = fruits.indexOf('orange');
console.log(orangeIndex); // 2
filter(): returns a new array containing all elements that pass a specified test.
let numbers = [1, 2, 3, 4, 5];
let evenNumbers = numbers.filter(function(number) {
return number % 2 === 0;
});
console.log(evenNumbers); // [2, 4]
map(): returns a new array containing the results of calling a function on each element in the original array.
let numbers = [1, 2, 3, 4, 5];
let squaredNumbers = numbers.map(function(number) {
return number * number;
});
console.log(squaredNumbers); // [1, 4, 9, 16, 25]
#javascript #array #arrayfunctions #function #functions #javascriptarrayfunction #javascriptarrayfunctions #shorts #short #shortsvideo #shortsfeed #shortfeed #shortvideo #shortsyoutube #shortviral #push #pop #shift #unshift #slice #splice #concat #indexof #filter #map #princecheema_official @princecheema_official
-
LIVE
The Pete Santilli Show
1 hour agoOur Memorial & Prayer Vigil For Charlie Kirk - September 15, 2025
809 watching -
LIVE
Welcome to the Rebellion Podcast
21 hours agoWhere Do We Go From Here? - WTTR Podcast Live 9/15
458 watching -
LIVE
The Chris Salcedo Show
16 hours agoFALLOUT: Charlie Kirk's Assassination
689 watching -
LIVE
The Bubba Army
2 days agoCharlie Kirk's Shooter, Had a Trans BF? - Bubba the Love Sponge® Show | 9/15/25
2,287 watching -
30:31
DeVory Darkins
14 hours ago $4.73 earnedCNN forced to admit the shocking truth about shooter as Fetterman drops bomb on Democrats
13.2K66 -
20:54
Professor Nez
16 hours ago🚨BREAKING: Shooter’s Own Words in Charlie Kirk Case Revealed
1.93K4 -
16:48
itsSeanDaniel
16 hours agoGenius Republican Defends Charlie Kirk and CALLS OUT The Radical Left
3.54K2 -
9:09
Freedom Frontline
16 hours agoFox News Just Showed The Video Biden Never Wanted Seen
14.6K15 -
0:27
historyofboxing
17 hours ago $0.13 earnedThe Cuban Machine… and Deadliest KO Phenom Right Now – David Morrell Jr
6.55K1 -
38:07
Degenerate Plays
15 hours ago $0.24 earnedWorst Star Wars Character Pranks Us All - Call of Duty: Modern Warfare 3 (2011) : Part 3
13.9K