Home | Mailing List | Blog | Tutorial Videos

Pick the Rotten Bean in an Array

There is a rotten bean which looks different inside a basket. Which option below is the right way to create a new array containing only the rotten bean?

var basket = [0, 0, 0, 0, 9];

// A 
basket.splice(4, 1);

// B
basket.slice(4, 1);

Select one: