Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Determine If an Argument is Sent to a JavaScript Function



To determine if an argument is sent to function, use “default” parameters.

Example

You can try to run the following to implement it

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <script>
         function display(arg1 = 'Tutorials', arg2 = 'Learning') {
            document.write(arg1 + ' ' +arg2+"<br>");
         }
         display('Tutorials', 'Learning');
         display('Tutorials');
         display();
      </script>
   </body>
</html>
Updated on: 2020-01-07T10:29:12+05:30

102 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements