JavaScript

push, pop, shift & unshift

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

push() shton në fund të vargut, pop() heq nga fundi, unshift() shton në fillim, shift() heq nga fillimi. .length tregon sa elemente ka.

EnglishEN

push() adds to the end of an array, pop() removes from the end, unshift() adds to the start, shift() removes from the start. .length tells you how many items there are.

Si ta mendosh

Si një radhë në dyqan: dikush hyn nga fundi (push), dikush del nga para (shift).

Lexoje në anglisht

Like a queue in a shop: someone joins at the back (push), someone leaves at the front (shift).

Shembull kodijavascript

const radha = ["Arta"];
radha.push("Dren");      // ["Arta", "Dren"]
radha.unshift("Ilir");   // ["Ilir", "Arta", "Dren"]
radha.shift();           // "Ilir"

Terma të lidhur