array-8

let arr = [1, 2, "test", "bob", false, 33];

/*
    For removing data from an array using 
    JavaScript we can, among other things, 
    use built-in methods like pop(), shift()
    and splice();
*/

//Remove first element
arr.shift();
console.log(arr);
//Output: [2, "test", "bob", false, 33]

//Remove last element
arr.pop();
console.log(arr);
//Output: [1, 2, "test", "bob", false]

//Remove several consecutive elements
arr.splice(0, 3);
console.log(arr);
//Output: ["bob", false, 33]

/*
    We previously used splice() to add 
    elements to an array. If we do not
    specify elements that we want to add, 
    but only specify starting position and 
    number of elements, those elements will be
    removed from an array, and returned as 
    an array.
*/