Can any one help tell me what's wrong with my Javascript code?
var a = ["zero", "one", "two", "three"];
for (var i in a) {
var sliced = a.slice(i + 1);
console.log(sliced);
}
the console log gives: ["one", "two", "three"],[],[],[]
but what I expected is: ["one", "two", "three"],["two", "three"],["three"],[]
So, why my code not work? And how should I code? Thanks a lot.
for..inloop?i + 1to confirm it’s really1,2,3, etc.for..inis always a string.for..in, where current element of iterable property is a string, not a number?