What does the following code output? function test(a, b = a * 2, c = a + b) { return [a, b, c]; } console.log(test(3));

JavaScript Professional Hard

JavaScript Professional — Hard

What does the following code output? function test(a, b = a * 2, c = a + b) { return [a, b, c]; } console.log(test(3));

Key points

  • Default parameters are evaluated at runtime
  • Parameters are assigned left to right
  • The output reflects the values of a, b, and c at the time of function execution

Ready to go further?

Related questions