Open EdwardZZZ opened 7 years ago
const str = 'abcdefg' console.log(str.substr(-1)); // g console.log(str.substring(str.length - 1)); // g const arr = [1, 2, 3, 4, 5, 6, 7] console.log(arr.slice(-1), arr); // [7] [1, 2, 3, 4, 5, 6, 7] console.log(arr.splice(-1), arr); // [7] [1, 2, 3, 4, 5, 6]