FIFO behavior for Array.pop in javascript? -


this question has answer here:

i want array method similar array.pop() exhibits first in first out behavior, instead of native filo behavior. there easy way so?

imagine javascript console:

>> array = []; >> array.push(1); >> array.push(2); >> array.push(3); >> array.fifopop(); 1      <-- array.pop() yields 3, instead 

you can use array.prototype.shift()

>> array = []; >> array.push(1); >> array.push(2); >> array.push(3); >> array.shift();  //outputs 1 , removes array 

https://developer.mozilla.org/fr/docs/web/javascript/reference/objets_globaux/array/shift


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -