Jyoti gupta
Jul 12, 2022

--

Problem statement :

Prototype for printing all the elememnts of the array.

Array.prototype.printElements = function(){

const arrayLength = this.length;

if(arrayLength){

for(let i=0;i<arrayLength;i++){

console.log(this[i])

}

}

}

const a = [1,2,3,4,5];

a.printElements();

--

--

Jyoti gupta
Jyoti gupta

Written by Jyoti gupta

Senior Software Developer@EqualExperts | ex-Paytm | ex-Thoughtworks | Ex-Rivigo https://github.com/guptajyoti845 | https://www.linkedin.com/in/jyoti-g-18522a111

Responses (1)