How to define DO NOTHING in JavaScript

Viewed 93025

I am displaying a confirm box in my app. When the user clicks on Okay, I close the window
when user clicks on Cancel, I want to do nothing but stay on the same page.

What should I write in place of DO_NOTHING?

    <a href="#" onclick="confirm('Do you wan to close the application ?')?window.close():DO_NOTHING')">Close the application ?</a> 

If I keep it empty it does not work. If I write any random string it works but displays string undefined error.

11 Answers
onclick="confirm('Do you wan to close the application ?')?window.close():() => {}')"

Arrow function that return an empty object, it basically does nothing

Why don't you just use &&?

<a href="#" onclick="confirm('Do you want to close the application ?') && window.close()">Close the application ?</a> 

Related