I have an array of objects like this
export const productArray = [
{
imgUrl: images.beautifulinwhite,
productName: "White Flowers",
oldPrice: "$45.99",
newPrice: "$35.99",
},
{
imgUrl: images.blueandpinkjeans,
productName: "Blue and Pink Jeans",
oldPrice: "$57.99",
newPrice: "$40.99",
},
{
imgUrl: images.girlinyellow,
productName: "Yellow Tshirt",
oldPrice: "$53.99",
newPrice: "$37.99",
},
{
imgUrl: images.ladyinblack,
productName: "Black Hoodie",
oldPrice: "$40.99",
newPrice: "$33.99",
},
]
How do I filter this array to only get the first two objects? I don’t want to filter them by their attributes. I want to filter using their indexes .