var object = { "main": [{ "id": "123", "name": "name 1" }, { "id": "234", "name": "name 2" }] }; var toFind = "name 1"; var filtered = object.main.filter(function(el) { return el.name === toFind; }); document.write(filtered);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter