参考MDN developer.mozilla.org/en-US/docs/…
The
slice()method returns a shallow copy of a portion of an array into a new array object selected fromstarttoend(endnot included) wherestartandendrepresent the index of items in that array. The original array will not be modified.
从以上定义可以看出,虽然第二个参数end是从0开始,但要注意的是,返回的数组中不包含end!!所以当start 和end相同时,返回的是[].
想要返回index 0 需要slice(0,1)