Last active
October 15, 2022 09:38
-
-
Save NhanKhangg98/4103c2ba7a67c3e592b4a4217b685113 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
//1 | |
const push = (array: number[], num: number) => { | |
array[array.length] = num; | |
return array | |
} | |
// 2 | |
const pop = (array: number[]) => { | |
array.length-- | |
return array | |
} | |
// 3 | |
const shift = (array: number[]): number[] => { | |
const [removed, ...newArr] = array | |
//array[array.length - 1] = 0 | |
return newArr; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment