Skip to main content

Truthy value & Falsy value in JavaScript

 JavaScript uses type-conversion to any value in a boolean context

So, the first question is what is the boolean context? A boolean context refers to that piece of code where we only consider true/false as output. For example, parentheses of if is a boolean context.

Now, what is falsy or truthy mean? Falsy is a value that is considered False when encountered in a boolean context and Truthy value is considered True when encountered in a boolean context.

There are 6 falsy values in JavaScript - undefined, null, NaN, "", 0, false. And rest of the values in a boolean context are considered as truthy.


Happy learning!


GitHub: 

https://github.com/mukitul/javascript-es6-rxjs/blob/main/src/es6-practice/truthy-and-falsy.js


Reference:

https://www.freecodecamp.org/news/falsy-values-in-javascript/

Comments

Popular posts from this blog

Part 1: Connecting AI to My Daily Tools – A Simple MCP-Powered TODO App

Imagine asking an AI to manage your TODO list, run a local script, or update a file - it does exactly that, like a virtual assistant plugged into your computer. This is now possible thanks to something called MCP ( Model Context Protocol ).  What is MCP?   MCP (Model Context Protocol) is a lightweight protocol proposed by Anthropic that enables AI models to interact with tools in a structured and transparent manner. It lets you define tools in an AI-readable format — including their names, parameters, descriptions, and return types — so that LLMs like Claude, GPT (and others) can understand and call them safely. With MCP, you can turn your scripts, utilities, and services into AI-callable tools, effectively giving the model "extensions" into your local environment or applications.  Image Source: fb.com/devtalks My First Experiment: A TODO List MCP Server   To explore MCP in action, I created a simple MCP server that exposes two tools:   đŸ“ addTodo(day,...

āĻ•িāĻ­াāĻŦে āωāχāύ্āĻĄোāϜ ā§§ā§Ļ āĻ Java/JDK ā§Ž āχāύ্āϏāϟāϞ āĻ•āϰāĻŦেāύ? JDK 8 installation guide!

āĻāχ āĻŦ্āϞāĻ—ে āφāĻŽāϰা āĻĻেāĻ–āĻŦো āĻ•িāĻ­াāĻŦে āĻāĻ•āϟি āωāχāύ্āĻĄোāϜ ā§§ā§Ļ āĻĒিāϏি āϤে Java/JDK āχāύ্āϏāϟāϞ āĻ•āϰāϤে āĻšā§Ÿ। Java āχāύ্āϏāϟāϞ āĻ•āϰা āĻŦāϞāϤে āφāĻŽāϰা āĻŦুāĻāĻŦো JDK āĻŦা Java Development Kit āχāύ্āϏāϟāϞ āĻ•āϰাāĻ•ে। āφāĻŽāϰা āĻāχ āĻŦ্āϞāĻ—ে āϜাāύāĻŦো āĻ•ি āĻ•āϰে Oracle JDK āĻāϰ āĻ­াāϰ্āϏāύ ā§Ž āχāύ্āϏāϟāϞ āĻ•āϰāϤে āĻšā§Ÿ। āϧাāĻĒ ā§§ঃ āĻĄাāωāύāϞোāĻĄ JDK ā§Ž āĻĄাāωāύāϞোāĻĄ āϞিāĻ™্āĻ•ঃ  https://www.oracle.com/java/technologies/downloads/#java8 āĻ…āĻĨāĻŦা  https://www.oracle.com/java/technologies/downloads/  āĻāχ āϞিāĻ™্āĻ• āĻ āĻ—ি⧟েāĻ“ āϏ্āĻ•্āϰāϞ āĻ•āϰে āύিāϚে āύেāĻŽে Java 8 choose āĻ•āϰāϤে āĻĒাāϰেāύ। Available product/file āĻ—ুāϞো āĻĨেāĻ•ে x64 Installer āĻāϰ .exe file āϟা āĻĄাāωāύāϞোāĻĄ āĻ•āϰি (āϤāĻŦে āφāĻĒāύাāϰ āĻĒিāϏি āϝāĻĻি 32-bit āĻ…āĻĒাāϰেāϟিং āϏিāϏ্āϟেāĻŽ āĻāϰ āĻšā§Ÿ, āϏেāĻ•্āώেāϤ্āϰে āφāĻĒāύি āĻĄাāωāύāϞোāĻĄ āĻ•āϰāĻŦেāύ x86 Installer āĻāϰ exe file āϟা-āĻ•ে)। āĻĄাāωāύāϞোāĻĄ āĻ•āϰাāϰ āϜāύ্āϝ Oracle āĻ āĻ…্āϝাāĻ•াāωāύ্āϟ āĻĨাāĻ•āϤে āĻšā§Ÿ। āφāĻĒāύাāϰ āϝāĻĻি āĻ…্āϝাāĻ•াāωāύ্āϟ āύা āĻĨাāĻ•ে āϤāĻŦে āĻ…্āϝাāĻ•াāωāύ্āϟ create āĻ•āϰে āύিāĻŦেāύ। Oracle āĻ āĻ…্āϝাāĻ•াāωāύ্āϟ create āĻ•āϰা āĻāĻ•āĻĻāĻŽ free of cost. āϧাāĻĒ ā§¨ঃ āχāύ্āϏāϟāϞ JDK ā§Ž āĻĄাāωāύāϞোāĻĄ āĻ•āϰা āĻšā§Ÿে āĻ—েāϞে .exe āϟাāϤে double click āĻ•āϰে āχāύ্āϏāϟāϞ āĻ•āϰা āĻļুāϰু āĻ•āϰি। āύিāϚেāϰ āĻ›āĻŦি āĻ—ুāϞোāϰ āĻŽāϤো āĻāĻ•āϟা āĻ•āϰা āωāχāύ্āĻĄো āφāĻĒāύাāϰ āϏাāĻŽāύে āĻ“āĻĒেāύ āĻšāĻŦে āĻāĻŦং āφāĻĒāύি Next button āĻ•্āϞিāĻ• āĻ•āϰে āϏাāĻŽāύে āĻāĻ—ি⧟ে āϝা...

JDK 17 installation guide | āĻ•িāĻ­াāĻŦে āωāχāύ্āĻĄোāϜ ā§§ā§Ļ āĻ Java/JDK ā§§ā§­ āχāύ্āϏāϟāϞ āĻ•āϰāĻŦেāύ? How to install JDK 17 on windows 10?

āĻāχ āĻŦ্āϞāĻ—ে āφāĻŽāϰা āϜাāύāĻŦো āĻ•িāĻ­াāĻŦে āωāχāύ্āĻĄোāϜ ā§§ā§Ļ āĻĒিāϏি āϤে Java/JDK āχāύ্āϏāϟāϞ āĻ•āϰāϤে āĻšā§Ÿ। Java āχāύ্āϏāϟāϞ āĻ•āϰা āĻŦāϞāϤে āφāĻŽāϰা āĻŦুāĻāĻŦো JDK āĻŦা Java Development Kit āχāύ্āϏāϟāϞ āĻ•āϰাāĻ•ে। āφāĻŽāϰা āĻāχ āĻŦ্āϞāĻ—ে Oracle JDK āĻāϰ āĻ­াāϰ্āϏāύ ā§§ā§­ āĻ•িāĻ­াāĻŦে āχāύ্āϏāϟāϞ āĻ•āϰāϤে āĻšā§Ÿ āϏেāχ āϧাāĻĒāĻ—ুāϞো āϜাāύāĻŦো।  āϧাāĻĒ ā§§ঃ āĻĄাāωāύāϞোāĻĄ JDK ā§§ā§­ āĻĄাāωāύāϞোāĻĄ āϞিāĻ™্āĻ•ঃ  https://www.oracle.com/java/technologies/downloads/#java17 āĻ…āĻĨāĻŦা  https://www.oracle.com/java/technologies/downloads/  āĻāχ āϞিāĻ™্āĻ• āĻ āĻ—ি⧟েāĻ“ āϏ্āĻ•্āϰāϞ āĻ•āϰে āύিāϚে āύেāĻŽে Java 17 choose āĻ•āϰāϤে āĻĒাāϰেāύ। Available product/file āĻ—ুāϞো āĻĨেāĻ•ে x64 Installer āĻāϰ .exe file āϟা āĻĄাāωāύāϞোāĻĄ āĻ•āϰি। āĻĄাāωāύāϞোāĻĄ āĻ•āϰাāϰ āϜāύ্āϝ Oracle āĻ āĻ…্āϝাāĻ•াāωāύ্āϟ āĻĨাāĻ•āϤে āĻšā§Ÿ। āφāĻĒāύাāϰ āϝāĻĻি āĻ…্āϝাāĻ•াāωāύ্āϟ āύা āĻĨাāĻ•ে āϤāĻŦে āĻ…্āϝাāĻ•াāωāύ্āϟ create āĻ•āϰে āύিāĻŦেāύ। Oracle āĻ āĻ…্āϝাāĻ•াāωāύ্āϟ create āĻ•āϰা āĻāĻ•āĻĻāĻŽ free of cost. āϧাāĻĒ ā§¨ঃ āχāύ্āϏāϟāϞ JDK ā§§ā§­ āĻĄাāωāύāϞোāĻĄ āĻ•āϰা āĻšā§Ÿে āĻ—েāϞে .exe āϟাāϤে double click āĻ•āϰে āχāύ্āϏāϟāϞ āĻ•āϰা āĻļুāϰু āĻ•āϰি। āύিāϚেāϰ āĻ›āĻŦি āĻ—ুāϞোāϰ āĻŽāϤো āĻāĻ•āϟা āĻ•āϰা āωāχāύ্āĻĄো āφāĻĒāύাāϰ āϏাāĻŽāύে āĻ“āĻĒেāύ āĻšāĻŦে āĻāĻŦং āφāĻĒāύি Next button āĻ•্āϞিāĻ• āĻ•āϰে āϏাāĻŽāύে āĻāĻ—ি⧟ে āϝাāĻŦেāύ। āϏāĻŦāĻļেāώে Close button āĻ•্āϞিāĻ• āĻ•āϰে āχāύ্āϏāϟāϞ āĻ•āϰা āϏāĻŽ্āĻĒāύ্āύ āĻ•āϰāĻŦেāύ। āϧাāĻĒ ā§Šঃ Environment Variable āϏেāϟāφāĻĒ S...