JS Tutorial

Function Reference

Method Reference

  • JS String
  • JS Array
  • JavaScript Arrow Function

    Arrow functions were introduced with ES6 for shorter function syntax

    Default Parameters in JavaScript

    The Default Parameter allows formal parameters to be initalize with default values if no value or undefined is passed

    Example 1 - ES6

    function sum(x,y=0)
    {
    	return x+y;
    }
    sum(5,4); // Output : 9
    sum(4); //Output : 4
    

    Example 2 - ES5

    function sum(x,y=0)
    {
    	y=( typeof y !==undefined) ? y:0;
    	return x+y;
    }
    sum(5,5); // Output : 10
    sum(6); //Output : 6