Es6 Default Values


// ES6 - Default values:

This is a thing that other language have had for a long time, and it is nice 
that JavaScript is catching up.

function getInfo(print=false) {
  if (print) {
    console.log(, this.age);
  } else {
    return `${} ${this.age}`;


In the above code, if the parameter print is not specified, it is automatically 
default to false so that we do not have to worry inside if it is not defined.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License