JRS: In article <11**********************@h48g2000cwc.googlegroups .com>,
dated Fri, 6 Oct 2006 16:49:42 remote, seen in
news:comp.lang.javascript, Carlos Aguayo <ca***********@gmail.com>
posted :
>Is there a better way to do this?
Yes.
>The problem that I have is that x can be "true" or "false" (as type
string), or true or false (as boolean type).
Within a program, away from I/O, a logical value with exactly two
significantly-different states should be a Boolean, and not a String.
You should convert the value to genuine Boolean as soon as it is
generated, if it is not already Boolean. The type will be known at
creation.
You should not ask your users to put "true" or "false" in a control that
inputs strings; you should use a checkbox instead.
If you are obliged to accept such strings, then convert to lower case,
compare with both "true" and "false", and decide what to do if neither
match.
It's a good idea to read the newsgroup and its FAQ. See below.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.