首页 > Web开发 > 详细

js中function参数默认值

时间:2017-01-14 14:48:23      阅读:202      评论:0      收藏:0      [点我收藏+]

参考: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;

这样就不会出现问题了。

 

js中function参数默认值

原文:http://www.cnblogs.com/zl0372/p/function_parmeter.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!