How to handle this case in javascript?

that was I am thinking but how?