We would like to know how to remove the third item from array of objects.
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
var arr = [{img: 1},
{img: 2},<!--from www . ja va 2 s.com-->
{img: 3},
{img: 4}];
for (var i = arr.length; i--;) {
if (arr[i].img === 3) {
arr.splice(i, 1);
}
};
document.writeln(JSON.stringify(arr));
</script>
</head>
<body>
</body>
</html>
The code above is rendered as follows: