Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

TOP Array Methods

ARRAY		  	 METHOD					DESCRIPTION
[1, 2, 3]		.push(4); 		inserts el. @ end of array	  	  // [1, 2, 3, 4]
[1, 2, 3]		.pop();   		removes el. @ end of array		  // [1, 2]
[1, 2, 3]		.shift(); 		removes el. @ beginning of array  // [2, 3]
[1, 2, 3]		.unshift(0); 	inserts el. @ beginning of array  // [0, 1, 2, 3]
['a', 'b']		.concat('c'); 	concatenated 2 diff. arrays 	  // ['a', 'b', 'c']
['a', 'b', 'c']	.join('-'); 	the argum. determine whats btw the array el.s // a-b-c
['a', 'b', 'c']	.slice(1); 		1st argum. the index, 2nd argum amount to be removed	// ['b', 'c']
['a', 'b', 'c']	.indexOf('b'); 	give the index on an el. in the array	// 1
['a', 'b', 'c']	.includes('c'); bool, is the argum in the array?  // true
[3, 5, 6, 8]	.find((n) => n % 2 === 0); 						  // 6
[2, 4, 3, 5]	.findIndex((n) => n % 2 !== 0); 				  // 2
[3, 4, 8, 6]	.map((n) => n * 2); basically looping in arrays	  // [6, 8, 16, 12]
[1, 4, 7, 8]	.filter((n) => n % 2 === 0); 					  // [4, 8]
[2, 4, 3, 7]	.reduce((a, b) => a + b);		 				  // 16
[2, 3, 4, 5]	.every((x) => x < 6); 							  // true
[3, 5, 6, 8]	.some((n) => n > 6); 							  // true
[1, 2, 3, 4]	.reverse(); 									  // [4, 3, 2, 1]
[3, 5, 7, 8]	.at(-2); 										  // 7	
Comment

PREVIOUS NEXT
Code Example
Javascript :: Quick JS DATE 
Javascript :: Html5 canvas resize image aspect ratio 
Javascript :: js calculate hours between two times 
Javascript :: Register Multiple Models In Admin 
Javascript :: joi custom validation read data for all fields 
Javascript :: mantine progress 
Javascript :: passing third parameter in context.commit vuejs 
Javascript :: regexp look for letter followed by 3 digits 
Javascript :: how to confirm if angular js in installed 
Javascript :: react js public folder image path search 
Javascript :: make react navigation to always re render 
Javascript :: convert h2 to h1 jQuery 
Javascript :: Include Path reactjs in VS code in in urud 
Javascript :: prime number in javascript using for loop 
Javascript :: how to check vowels in a string in javascript 
Javascript :: react word cload 
Javascript :: javascript$.4908BEAMpacidE 
Javascript :: highcharts hide gaps 
Javascript :: on page navigate event javascript 
Javascript :: jquery keypress div color change 
Javascript :: submit form on ctrl enter 
Javascript :: react onwheel preventDefault 
Javascript :: Multiple Locale Support momentjs 
Javascript :: javascript assigning index number to row in table 
Javascript :: Make a card dynamic with Angular JS 
Javascript :: angularjs NodeJS server performs POST request, but returns HTTPErrorResponse 
Javascript :: Filtering smart-table on transformed data 
Javascript :: change useragent cypress test run 
Javascript :: react open popup to upload image file 
Javascript :: make field un updatable mongoose 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =