2016年6月21日 星期二

String.IsNullOrEmpty in JavaScript

Starting with:
return (!value || value == undefined || value == "" || value.length == 0);
Looking at the last condition, if value == "", it's length MUST be 0. Therefore drop it:
return (!value || value == undefined || value == "");
But wait! In JS, an empty string is false. Therefore, drop value == "":
return (!value || value == undefined);
And !undefined is true, so that check isn't needed. So we have:
return (!value);
And we don't need parentheses:
return !value
Q.E.D.


http://codereview.stackexchange.com/questions/5572/string-isnullorempty-in-javascript

2016年6月2日 星期四

[jQuery]add dynamic rows



Ref:
http://stackoverflow.com/questions/2145012/adding-rows-dynamically-with-jquery

http://ssiddique.info/different-ways-to-add-row-to-a-table-using-jquery.html

http://stackoverflow.com/questions/16183231/jquery-append-and-remove-dynamic-table-row