I created a function like this:
function saveItem(andClose = false) {
}
It works fine in Firefox
In IE it gives this error on the
You can't do this, but you can instead do something like:
function saveItem(andClose) {
if(andClose === undefined) {
andClose = false;
}
}
This is often shortened to something like:
function setName(name) {
name = name || 'Bob';
}
Update
The above is true for ECMAScript <= 5. ES6 has proposed Default parameters. So the above could instead read:
function setName(name = 'Bob') {}