Here is my code:
$('#pageForward').append(' detailUser +','+ detailDate +','+ detailUserName + ','+ previousPage +');"开发者_开发技巧> >>');
The string builds, but if my variables are null, I get a syntax error:
[Break On This Error] getSDDetailPopUp(Accounting,,,,2);
How do I get this string to be this: getSDDetailPopUp(Accounting,'','','',2);
Thanks!
use || as a null coalescing operator.
... detailUser || "" +
...
For each of your params you can just do...
(detailUser != null ? detailUser : "''")
精彩评论