In ES2015, a developer can add a default parameter into a function. Example:
function loadProfile(usernames=[]){
if (usernames.lenght > 3){
let loadingMessage ="This will take a while.";
}
}
With default parameter, you can call the function either
loadProfile(['Simon','Alex','Arlene']);
Or
loadProfile();
Scala has more powerful default parameter. Let's create Scala function with default parameter.
def addInt(a:Int=5, b:Int=7) = {
var sum: Int = a + b;
return sum
}
You can call the function by passing the parameter using a pointer.
addInt(b=10)
Passing parameter using pointer is not implement in JavaScript.
No comments:
Post a Comment