var sampleArray = [1,2,3,4];// Declaring the array
var lastElement = sampleArray.pop();//this command will remove the last element of `sampleArray` and stores in a variable called `lastElement` so that you can use it if required.
现在的结果是:
console.log(sampleArray); //This will give you [1,2,3]
console.log(lastElement); //this will give you 4
myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var newArrayOfThings = myArray
.filter(x => x > 5) // only bigly things
.slice(0, -1) // get rid of the last item ! slice(-1) will give first element
.map(x => `The number is: ${x}`);// map to a set of strings
myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var newArrayOfThings = myArray
.filter(x => x > 5) // only bigly things
.slice(-1) // get rid of the "10"
.concat([100]) // note with concat, you must pass an array
.map(x => `The number is: ${x}`) // map to a set of strings