js中function参数默认值

参考:http://www.cnblogs.com/silverLee/archive/2009/12/30/1635942.html

某个JS函数定义如下

function update_question(current_studentId,current_questionId,current_index,current_taskId,update_bool=false){

在firefox、chrome下均没有问题,后来发现在Chrome低版本 47.0.2526.80 (64-bit)下出现如下错误:

Uncaught SyntaxError: Unexpected token =

参考本文所说的文章,将代码替换为以下:

function update_question(current_studentId,current_questionId,current_index,current_taskId,update_bool){
    if(!arguments[4]) update_bool = false;

这样就不会出现问题了。

原文地址:https://www.cnblogs.com/zl0372/p/function_parmeter.html