//Concat
['ππ»ββοΈ', 'ππ»'].concat('π§π»') = [ 'ππ»ββοΈ', 'ππ»', 'π§π»' ]
//Join
['π€΄π»', 'πΈπ»'].join('π') = 'π€΄π»ππΈπ»'
//Slice
['π', 'πΆ', 'π'].slice(2)= [ 'π' ]
//Index of
['0οΈβ£', '1οΈβ£', '2οΈβ£', '3οΈβ£'].indexOf('1οΈβ£') = 1
//Includes
['0οΈβ£', '1οΈβ£', '2οΈβ£', '3οΈβ£'].includes('1οΈβ£') = true
//Every
[
{label: '0οΈβ£', type: 'emoji'},
{label: '1οΈβ£', type: 'emoji'},
{label: '2οΈβ£', type: 'emoji'},
{label: '3οΈβ£', type: 'emoji'}
].every(item => item.type === 'emoji') = true
//Some
[0, '1οΈβ£', '2οΈβ£', '3οΈβ£'].some(item => typeof item === 'number') = true
//Fill
['π', 'π', 'π'].fill('π€ͺ') = [ 'π€ͺ', 'π€ͺ', 'π€ͺ' ]
// Map
['0οΈβ£', '1οΈβ£', '2οΈβ£', '3οΈβ£'].map((item, index) => item + " -> " + index) = [ '0οΈβ£ -> 0', '1οΈβ£ -> 1', '2οΈβ£ -> 2', '3οΈβ£ -> 3' ]
// Map
['0οΈβ£', '1οΈβ£', '2οΈβ£', '3οΈβ£'].filter((item, index) => index === 1) = [ '1οΈβ£' ]
//Reduce
['0οΈβ£', '1οΈβ£', '2οΈβ£', '3οΈβ£'].reduce((acc, current) => acc + current) = '0οΈβ£1οΈβ£2οΈβ£3οΈβ£'
//Push
['π€¬', 'π‘', 'π', 'π'].push('π') = 5 // it will insert 'π' to list at last
//unshift
['π‘', 'π', 'π', 'π'].unshift('π€¬') = 5 // it will insert 'π€¬' to list at first
//Pop
['π€¬', 'π‘', 'π', 'π', 'π'].pop('π') = 'π' // it will remove 'π' from list
//Shift
['π€¬', 'π‘', 'π', 'π', 'π'].shift() = 'π€¬' // it will remove 'π€¬' from list
//Reverse
['π€¬', 'π‘', 'π', 'π', 'π'].reverse() = [ 'π', 'π', 'π', 'π‘', 'π€¬' ]
Thank you!!
Cheers!!
Top comments (5)
let arr = [0,1,2,3,4,5,6,7,8,9,10] - Input
let arr = [10,1,2,3,4,5,6,7,8,9,0] - output
Please explain how to rearrange.
Thank you so much!
I am beginner in javaScript, If possible can you expalin the code.
We are sorting the array in ascending order after ascend ascending the array will be like this [0,1,2,3,4,5,6,7,8,9,10]. Later we need to swap first and last element in the array
ok, noted thank you so much.