vm.fetchData = ($index) => {
}
I want to make $index
as optional parameter.
vm.fetchData = ($index) => {
}
I want to make $index
as optional parameter.
Since you don't explicitly can declare parameters as optional in vanilla JS, you could simply ignore them in the function body:
vm.fetchData = function($index) {
if(typeof $index == 'undefined') {
// following should happen if parameter is missing
} else {
// following requires a parameter
}
// do the rest and return
}
See also: