swanwish / blog

My blog website
0 stars 0 forks source link

Javascript change value through arguments #16

Open swanwish opened 7 years ago

swanwish commented 7 years ago
function test(a, b, c, d, e) {
    console.log(a,b,c,d,e);
    for (var i=0; i<arguments.length; i++) {
        if (arguments[i] == null) {
            arguments[i] = '~~';
        }
    }
    console.log(a,b,c,d,e);
}

Call the function with: test(10, 20, null, null, 50), get the results as below:

10 20 null null 50
10 20 "~~" "~~" 50