Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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());
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #How #optional #function
ADD COMMENT
Topic
Name
3+9 =