This content originally appeared on DEV Community and was authored by Md. Azad Ul Kabir
There are two most important terms to understand when you execute some code based on an "if else" statement. Truthy and Falsy value.
Truthy value: Data types that return true by default are called truthy.
False value: Data types that return false by default are called falsy
- All values are truthy except these values
- +0 or -0
- BigInt zero (0n)
- Empty String ("")
- null, undefined, and NaN
For example below this code we are performing a Linear search. But when I apply a condition for "value not found" I have a complexity for array index 0. I solved this in my way. But there are several ways to solve this.
This content originally appeared on DEV Community and was authored by Md. Azad Ul Kabir
Md. Azad Ul Kabir | Sciencx (2023-03-02T05:34:31+00:00) Truthy And Falsy Value In JavaScript.. Retrieved from https://www.scien.cx/2023/03/02/truthy-and-falsy-value-in-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.