Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript optional parameters

const myFunction = (str, id=0) => {
	console.log(str, id)
} 
myFunction("Hello Grepper")
// OUTPUT : "Hello Grepper 0"

myFunction("HG", 10)
// OUTPUT : "HG 10"
 
PREVIOUS NEXT
Tagged: #javascript #optional #parameters
ADD COMMENT
Topic
Name
4+7 =