DEV Community

Cover image for 𝐃𝐞𝐟𝐢𝐧𝐞 𝐩𝐨𝐩,𝐩𝐮𝐬𝐡,𝐬𝐡𝐢𝐟𝐭,𝐮𝐧𝐬𝐡𝐢𝐟𝐭 𝐌𝐞𝐭𝐡𝐨𝐝𝐬 𝐢𝐧 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭
Jahid Iqbal
Jahid Iqbal

Posted on

𝐃𝐞𝐟𝐢𝐧𝐞 𝐩𝐨𝐩,𝐩𝐮𝐬𝐡,𝐬𝐡𝐢𝐟𝐭,𝐮𝐧𝐬𝐡𝐢𝐟𝐭 𝐌𝐞𝐭𝐡𝐨𝐝𝐬 𝐢𝐧 𝐉𝐚𝐯𝐚𝐒𝐜𝐫𝐢𝐩𝐭

𝐩𝐨𝐩(): 𝑅𝑒𝑚𝑜𝑣𝑒 an item from the 𝑒𝑛𝑑 of an 𝑎𝑟𝑟𝑎𝑦.

𝐸𝑥𝑎𝑚𝑝𝑙𝑒
let players = ['Shakib', 'Tamim', 'Mushfiq'];
players.pop(); // ['Shakib', 'Tamim']

𝐬𝐡𝐢𝐟𝐭():𝑅𝑒𝑚𝑜𝑣𝑒 an item from the 𝑏𝑒𝑔𝑖𝑛𝑛𝑖𝑛𝑔 of an array.

𝐸𝑥𝑎𝑚𝑝𝑙𝑒
let players = ['Shakib', 'Tamim','Mushfiq' ];
players.shift(); // ['Tamim','Mushfiq']

𝐩𝐮𝐬𝐡(): 𝐴𝑑𝑑 items to the 𝑒𝑛𝑑 of an array.

𝐸𝑥𝑎𝑚𝑝𝑙𝑒
let rivers= ['Meghna'];
rivers.push('Jamuna'); // ['Meghna', 'Jamuna']

𝐮𝐧𝐬𝐡𝐢𝐟𝐭(): 𝐴𝑑𝑑 items to the 𝑏𝑒𝑔𝑖𝑛𝑛𝑖𝑛𝑔 of an array.

𝐸𝑥𝑎𝑚𝑝𝑙𝑒
let fruits= ['Mango'];
fruits.unshift('Orange'); // ['Orange', 'Mango']

Top comments (0)