Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

optional function parameter javascript

function check(a, b = 0) {
  document.write("Value of a is: " + a + 
                 " Value of b is: " + b + 
                 "<br>");
}
check(9, 10);
check(1);
Comment

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"
Comment

optional function call js

obj.val?.prop
obj.val?.[expr]
obj.arr?.[index]
obj.func?.(args)
Comment

javascript How can i do optional function

const db = { input() { return { query() { return 'db.input(...).query(...)'; } } }, query() { return 'db.query(...)'; } };

console.log((true ? db.input() : db).query());
console.log((false ? db.input() : db).query());
Comment

PREVIOUS NEXT
Code Example
Javascript :: start animation with javascript 
Javascript :: how to subtract time in javascript 
Javascript :: list of alphabet letter english for js 
Javascript :: javascript set cookie 
Javascript :: push in object javascript 
Javascript :: js array last element 
Javascript :: how to make a progress bar in react 
Javascript :: get % of number javascript 
Javascript :: mongoose populate 
Javascript :: remove duplicates javascript 
Javascript :: javascript initialize two array in one line 
Javascript :: split and join in javascript 
Javascript :: javascript set style attribute 
Javascript :: js reduce example 
Javascript :: Expected an identifier and instead saw ' 
Javascript :: remove from string javascript regex 
Javascript :: button disable in js 
Javascript :: proxy api javascript get 
Javascript :: nodejs global 
Javascript :: how to get the last element in javascript 
Javascript :: javascript array sorting 
Javascript :: countdown js 
Javascript :: react-data-table-component cell action stack overflow 
Javascript :: vue style background color 
Javascript :: expo dependencies 
Javascript :: how to compare previous value with current in jquery 
Javascript :: input set variable angular 
Javascript :: javaScript new Set() Method 
Javascript :: javascript cookies vs session vs local storage 
Javascript :: javascript how to do if else 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =