Thursday 24 May 2018

javascript - String check with if js shorthand

I have var names = []; and want push there some string only if it's not empty. Is there way make it with some shorthand method in js?)



That i have now.



 if ("" != opportunityName) 
{
names.push(opportunityName);
}



And that Don't wotk for me, it's push empty string.



names.push(opportunityName || "");

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...