Alternative for ".shift()" for arrays?
-
Hi everyone,
Is there an alternative for using the function ".shift()", which removes the first element in an array?
-
var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.remove(fruits[0]);
-
@d-healey said in Alternative for ".shift()" for arrays?:
fruits.remove(fruits[0]);
I was trying to remove the item only by its index...
Works like a charm now. Thanks!
-
@Alex-Paradis please take some time with this sort of thing to check things like this:
W3Schools.com
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
(www.w3schools.com)
-
@Lindon
In fact, this is where I found the function and saw that code.var fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.shift();
I didn't know that for Hise you also have to add the array plus its index in the "remove()" function but anyway, it's all good for now.
-
@Alex-Paradis then you probably also saw this one:
W3Schools.com
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
(www.w3schools.com)