We have a loop like this:
for (var prop in obj) {
if (obj.hasOwnProperty(prop) {
// Here need operation only for first iteration (1)
// Other operations
}
}
How can we identify first iteration in (1)?
you can use forEach
array.forEach((element,index) => {
if(index==0){
// first element
}else{
// not first element
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With