The live example link http://embed.plnkr.co/VgRD8B/ //DECLARE OPTIONAL PARAMETERS IN BELOW FUNCTION function myFunction(i, j) { i = i || 0; j = j || 0; //IN THE ABOVE LINE, (i/j) WILL BE SET EITHER TO VALUE OF (i/j) OR TO DEFAULT VALUE (0). } For example in detail < !DOCTYPE html > < html > < head > < meta charset ="utf-8" /> < title > J avaScript optional arguments in function </ title > < script src ="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></ script > < script > //DECLARE OPTIONAL PARAMETERS IN BELOW FUNCTION function myFunction(i, j) { i = i || 0; ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers