Javascript Boolean Inconsistencies - 'true' == true, but 'false' != false

RESOLVED INVALID

Status

()

Firefox
General
RESOLVED INVALID
11 years ago
11 years ago

People

(Reporter: Ole Ersoy, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070417 Fedora/2.0.0.3-4.fc7 Firefox/2.0.0.3
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070417 Fedora/2.0.0.3-4.fc7 Firefox/2.0.0.3

The summary is not literally true, but just there to give a brief idea of the issue.

The following examples will result in an alert:

        if ('true')
        {
        alert('hi');
        }

        var t = false

        if (!t)
        {
        alert('hi');
        }

Therefore we should expect an alert with this too:

        var t = 'false'

        if (!t)
        {
        alert('hi');
        }

But an alert is not triggered.

Reproducible: Always

Steps to Reproduce:
See details
Actual Results:  
See details

Expected Results:  
See details
(Reporter)

Comment 1

11 years ago
Never Mind...

I just realized that anything enclosed in '' or "" is a true value.  In order for something to be false it has to be false or 0, otherwise it's true.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
Resolution: FIXED → INVALID
You need to log in before you can comment on or make changes to this bug.