I read here that i can add a key:value
to an object
only if the value is not null otherwise the key:value
will not be there at all :
var product = {
coverTitle:document.getElementById("coverTitle").value.length>0 ? getElementById("coverTitle").value : undefined,
..
..
Will print :
coverTitle:undefined
I expect to not have this key inside at all.
I read it here : In Javascript, how to conditionally add a member to an object?
answer by Frédéric Hamidi
When uploading to a server I do not want to write this pair at all, like they are not there. What am I doing wrong ?