3
In PHP, I can make a function have by default a value in a parameter.
Example:
function func($a = 1, $b = 2) {
return $a + $b;
}
What about Javascript? I can make the same statement on Firefox 39
;
function b (a=1) {
return a;
}
But the recommendation I always see is:
function b (a) {
a = a || 1;
return a;
}
Why not use the default setting of a parameter, as is done in PHP, since it is possible to do this?
Is there a restriction on the browser version used?
Observing: When you said what is the safe way, I refer to the security that something will work in any browser, regardless of version.
+1 Interesting. How the genius guys will do something that only works in
Firefox
!?!?– Wallace Maxters
@Wallacemaxters would also like to know rsrsrs...
– Isa