HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <h1>JSON Deleting an Object</h1> <button onclick="myFunction()">Click Me</button> <script> var data = [ { "name": "Mike", "age": 36 }, { "name": "Jack", "age": 28 }, ] function myFunction(){ // Delete jack (object) from data data.splice(1, 1); console.log(data); } </script> <p><strong>Note</strong>: Click on the button and check your console.</p> </body> </html>
OUTPUT
×

Save as Private