Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Truth value
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Computing == {{see also|Implicit type conversion}} In some programming languages, any [[Expression (computer science)|expression]] can be evaluated in a context that expects a [[Boolean data type]]. Typically (though this varies by programming language) expressions like the number [[zero]], the [[empty string]], empty lists, and [[Null pointer|null]] are treated as false, and strings with content (like "abc"), other numbers, and objects evaluate to true. Sometimes these classes of expressions are called '''falsy''' and '''truthy'''. For example, in [[Lisp (programming language)|Lisp]], [[Null pointer|nil]], the empty list, is treated as false, and all other values are treated as true. In [[C (programming language)|C]], the number 0 or 0.0 is false, and all other values are treated as true. In [[JavaScript]], the empty string (<code>""</code>), <code>null</code>, <code>undefined</code>, [[NaN|<code>NaN</code>]], +0, [[β0]] and <code>false</code><ref>{{cite web |url=http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf |title=ECMAScript Language Specification |page=43 |url-status=dead |archive-url=https://web.archive.org/web/20150412040502/http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf |archive-date=2015-04-12 |access-date=2011-03-12 }}</ref> are sometimes called ''falsy'' (of which the [[Complement (set theory)|complement]] is ''truthy'') to distinguish between strictly [[Type safety|type-checked]] and [[Type conversion|coerced]] Booleans (see also: [[JavaScript syntax#Type conversion]]).<ref>{{cite web |url=http://javascript.crockford.com/style2.html |title=The Elements of JavaScript Style |publisher=Douglas Crockford |access-date=5 March 2011 |url-status=live |archive-url=https://web.archive.org/web/20110317074944/http://javascript.crockford.com/style2.html |archive-date=17 March 2011 }}</ref> As opposed to Python, empty containers (Arrays, Maps, Sets) are considered truthy. Languages such as [[PHP]] also use this approach.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)