Default parameters in ES6 functions.
ES6 is called ECMA Script2015 . As we know we do not have options in ES5 to declare the default parameters .
So in ES5 we make the things like this
var demo = function(name, address){
var name = name || "John";
var address = address || "USA";
// Code
}
But in ES6 we can declare the default parameters like
var demo = function (name = 'John', address = 'USA' ) {
// So here we can use the parameters directly.
}
Please like this article if it really helped you .
So in ES5 we make the things like this
var demo = function(name, address){
var name = name || "John";
var address = address || "USA";
// Code
}
But in ES6 we can declare the default parameters like
var demo = function (name = 'John', address = 'USA' ) {
// So here we can use the parameters directly.
}
Please like this article if it really helped you .
Comments
Post a Comment