【发布时间】:2012-03-21 16:46:48
【问题描述】:
我找不到类似的问题,我想这是因为我找不到正确的问题/答案。 我想创建一个函数,如果在调用函数时没有传递参数,则该函数将使用默认值,如果是这样,请将默认值替换为函数参数中传递的值。 例如:
function openBlock(false){
// if parameter was passed with 'false' value, it will do this
// else it will put automatically a 'true' value to an function's argument
}
所以如果调用一个没有任何参数的函数openBlock(),它会默认认为它是参数true。如果我调用带有参数false 的函数,例如openBlock(false),它将覆盖默认行为。
谢谢
【问题讨论】:
标签: javascript function if-statement arguments