Default Function Params In Javascript

In #javascript with es6 you can pass in default parameters in functions. This is useful as having a default for a function can provide a safeguard for your applications.

function getStudent(name, grade = 'F', age = 15) {
	return `${name} is ${age} years old and received ${grade}`;
}

getStudent('Frankie', 'B');
> "Frankie is 15 years old and received B"

getStudent('Mary', 'A', 14);
> "Mary is 14 years old and received A"

getStudent('Lilla');
> "Lilla is 15 years old and received F"

Read more about it here

Instagram Post