9/18/2019 12:57:40 AM
Paul Perez3 Answers
New AnswerWhenever you need something to be either true or false, and nothing else. Say you want some code to run only if a different piece of code ran. Since ran/not ran is a binary choice, boolean datatype would make sense here. Python example: x = 2 ran =False if x == 3: x += 1 ran = True if ran: x += 2 Now, this is toy example, but Booleans can be very useful.
Hi Paul Perez, Generally boolean variables are used to check the conditions. If you want to manipulate DOM on the basis of condition then you required boolean variables for manipulation. Example, I am working in angular so I use boolean variable to hide or display some input fields of the form.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message