I have a javascript object which has a large amount of key value pairs in it, among them some of the keys have a value as undefined. I what to delete the keys which have the value as undefined.
How can I achieve it?
You could do like below:
for(var k in obj) {
if (typeof obj[k] == 'undefined') {
delete obj[k];
}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.