Javascript examples for Object:Object Literal
Remove and delete key-value pair from object literal
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w w w . j ava2 s . c o m*/ var myObj = { style: "test", origin: "Thailand", day: "18d", color: "", abc: "", def: undefined, weight: null } for(var keys in myObj){ if(myObj[keys] ===null || myObj[keys] == ""){ delete myObj[keys] } } console.log(myObj) } </script> </head> <body> </body> </html>