I want to write a program to get nth element of given array in javascript. Using javascript methods. Also do not want to use slice. Please guide me on this.
I have tried this
const array = [1, 2, 3, 5]
function filterItems(array, index) {
return array[index];
}
console.log(filterItems(array, 0));
this will output 1. but how to do using javascript methods and without using slice

Uday DodiyaPosted Jan 6, 2023, 5:36 AM
Refer the @Mahesh Chand sir latest article about How to find nth element of Array using Javascript methods?
https://www.c-sharpcorner.com/article/how-to-find-nth-element-of-array-using-javascript-methods/
Aravind GovindarajPosted Jan 5, 2023, 12:45 PM
Vishal YelvePosted Jan 5, 2023, 11:16 AM
Jignesh KumarPosted Jan 5, 2023, 8:17 AM
Hello Aniket,
You can create function and use that function as below,
Above one will give Out put : 3