No,
The answer could be: new Object("false"), new Object(false);
Is this a bug?
If the code - alert( "if: "+ typeof b ); - results in the alerting of
"if: false" when - b - is either of - new Object("false") - or - new
Object(false) - then that most definitely is a bug. The specified result
of the - typeof - operation would be the string "object".
In addition (and if I can be bothered to look-up the section numbers for
you the least you could do is read them) the detention of Built-in
objects reads:-
| A built-in object is any object supplied by an ECMAScript
| implementation, independent of the host environment, which
| is present at the start of the execution of an ECMAScript program.
| Standard built-in objects are defined in this specification, and an
| ECMAScript implementation may specify and define others. Every
| built-in object is a native object.
- and the results of both of - new Object("false") - and - new
Object(false) - fail to satisfy the condition of being "present at the
start of the execution of an ECMAScript program". So they are not
built-in objects.
It looks to me like your intended code would have been - alert( "if: "+
b ); - and you were trying to point out that the type-conversion to
string values of some objects, which are true (or have trueness) by
virtue of being objects, may still be the string "false".
It is a pity that all my talk of the - typeof - operator did not tip you
off that something must be up.
Now if you were looking for a built-in object that had these
characteristics the - Boolean.prototype - would satisfy that
requirement, being an instance of the Boolean object with a 'false'
value, and existing from the start of the execution of an ECMAScript
program.
Of course a question to which the answer was - Boolean.prototype - would
not come well from someone who objected to questions using - with - on
the grounds that they did not ever use - with -, because I have seen
people using - with - but I am yet to any real code contain any
references to - Boolean.prototype -.
new Boolean( false ); will produce the same result in
IE and in FF, I think this is a bug.
It is not a bug. The specification requires - new Object(false) - to be
the exact equivalent of - new Boolean(false) - and - new
Object("false") - to be the exact equivalent of - new String("false") -.
So if your "b is a ... ; not a String or string literal" where taken as
referring to String objects and string primitives then - new
Object("false") - would not be allowed anyway (the resulting value is a
String object).
Richard.