在函數裡設定參數預設值
短摘:
function foo(a, b, c) {
a = a || "AAA";
b = b || "BBB";
c = c || "CCC";
document.write('a: ' + a + ' ');
document.write('b: ' + b + ' ');
document.write('c: ' + c + ' ');
document.write('<br />');
}
foo(1, '', 3);
No comments:
Post a Comment