What is the order of evaluation for function arguments in Javascript?

前端 未结 3 940
无人及你
无人及你 2020-12-01 16:05

According to my tests it is always left-to-right

>> console.log( console.log(1), console.log(2) );
1
2
undefined undefined

but I can\

3条回答
  •  时光说笑
    2020-12-01 16:37

    For historical interest, also see section 4.2 Evaluation Order of JavaScript 1.1 Language Specification (Brendan Eich, C. Rand Mckinney, 11/18/96).

    In a function or constructor call, one or more argument expressions may appear within the parentheses, separated by commas. Each argument expression is fully evaluated before any part of any argument expression to its right is evaluated.

提交回复
热议问题