ECMAScript 6 :
<script>
var e = function(a=1,b=2,c=3){
return a+b+c;
}
console.log(e());
</script>
Result is 6
script write by ECMAScript 2015:
<script>
var e = function e() {
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var c = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
return a + b + c;
};
console.log(e());
</script>
No comments :
Post a Comment