Why default arguments are immutable inside of a function in javascript?

Why , in javascript, the default arguments cannot be changed inside of a function and the non-default ones can?

function func(a) {
  a = 99; // updating a also updates arguments[0]
  console.log(arguments[0]);
}
func(10); // prints 99

vs

function func(a = 55) {
  arguments[0] = 99; // updating arguments[0] does not also update a
  console.log(a);
}
func(10); // prints 10

112 thoughts on “Why default arguments are immutable inside of a function in javascript?”

Leave a Comment