Created
August 18, 2021 06:13
-
-
Save pradeeprjth/aef8765f476a7a3924e08e2fa1e2452a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear() | |
var mFriends = ['Shaw', 'Clara', 'Vab', 'Kun', 'Jacob', 'Dina'] | |
mFriends.splice(3, 0, 'Donna', 'Rachel') | |
// 1st tells where to start | |
// 2nd tells how many items to be deleted | |
// 3rd and 4th and so on tells what items to be added | |
console.log(mFriends) | |
mFriends.splice(0, 0, 'Harvey') | |
console.log(mFriends) | |
// Delete item at specific position | |
mFriends.splice(2, 1) | |
console.log(mFriends) | |
mFriends.splice(0, 2) | |
console.log(mFriends) | |
// Concatenation | |
var mOfficeFriends = ['Nina', 'Aron', 'Katie', 'Vic', 'Paula'] | |
var mAllFriends = mFriends.concat(mOfficeFriends) | |
console.log('====================================') | |
console.log(mFriends) | |
console.log(mOfficeFriends) | |
console.log(mAllFriends) | |
//Sorting Ascending and Descending | |
mAllFriends.sort() | |
console.log(mAllFriends) | |
mAllFriends.reverse() | |
console.log(mAllFriends) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment