Why javascript forEach loop is not iterating complete array with splice

I was playing with javascript .splice() and .forEach() methods, the code is working fine, But it is not giving output as expected. the issue is that .forEach() runs for half array and then exits. what i expect output be is [[‘Apple’],[‘Banana’],[‘Mango’],[‘Pomegranate’]] But output is [[‘Apple’],[‘Banana’]] I am not able to figure it out that why…

Javascript how to identify button clicked

I have a page with many articles. Each article has a delete button. How can I identify the button clicked for the article? Currently I have this: <button type=”button” id=”delete-article” class=”btn btn-small btn-danger”>Delete</button> $(‘#delete-article’).on(‘click’, function(e) { console.log(‘Test delete article’); }); This logs ‘Test delete article’ according to the number of articles on the page.