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 . 

Comments

Popular posts from this blog

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

The transaction is aborted or Failure while attempting to promote transaction.

Unable to load one or more breakpoints in Visual studio.