const test = (
(success) => {
console.log('SUCCESS CALLED');
},
(error) => {
console.log('ERROR CALLED');
}
);
test(); // output is **ERROR CALLED**
In the above javascript code, is there anyway to output SUCCESS CALLED without changing the definition
There is no way to do this
The definition of the comma operator is that it evaluates the expressions in order, from left-to-right, and the overall expression is the result of the final expression evaluated (the right-most).
testnever contains any information about the success-oriented function, so there is no way to maketestinvoke it without altering something in the definition oftest.