Chrome's null Bug | SoloLearn: Learn to code for FREE!


Chrome's null Bug

Chrome has a bug,I was testing prompt in JavaScript in it,and put if and if else and else in it,which if the prompt was empty which means null,it calls hello anonymous and so on,but instead it says hello null,and the rest of my another if which was else and last if statement.check the code with chrome,Thanks A Lot!

3/24/2018 11:31:36 AM

Naeim Rahimzade

10 Answers

New Answer


I checked with chrome and it operates as expected. No input and OK pressed, Mr smart Input and OK pressed, Mr <input> Cancel pressed, Mr anonymous


What do you actually want to do here? It returns 'mr.null' only if you enter null in the prompt & that's your default condition when no input is matched. If you add another else if to check for literal null string it can alert a different text message. If that's what you want to do.


The behaviour is same on firefox. It's not a bug that's the expected output. when you cancel the prompt, return value is null. When it's pressed ok without a value it's empty string. # Read below for info about prompt.


It displays Mr Smart when no name entered but OK clicked and Mr Anonymous when cancel button clicked!* *(Here)


@Raj Srivastava Y U DO DIS? 😂


@Jay I'd love to send the picture of my chrome saying Mr.null 😂😞


@Lord Krishna it works fine with the empty one and pressing Ok,cuz it gives the answer I want,problem is,chrome seems like not knowing what null is, or not wanting to receive it,what I'm looking for is an alternative for null in Chrome


@Lord Krishna I'm not looking for The Null,I'm Saying what should I put instead of null Because this version of chrome I'm using doesn't accept null as the code,playground is fine with it,IE too,but only chrome has problem with it


@Naveen Maurya You checked it with chrome?


I meant pc chrome guys,if it's ok