javascript code:
window.mybooks={"books": [{"name":"book one","author":"Samuel Peter"},{"name":"book two","author":"Samuel Anderson"}]};
How to add new book to window.mybooks ?
{"name":"book three","author":"Samuel Abelson"}
UPDATE:
strange , a lot of same answers, and not working for me... what can cause this ?
I did found that the object is generated, maybe incorrectly. It looks like this:
window.mybooks={"books": [{"name":"book one","author":"Samuel Peter"},{"name":"book two","author":"Samuel Anderson"},]};
any hints how to correct it and mayabe then push will work ?
window.mybooks.books.push({"name":"book three","author":"Samuel Abelson"});
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