Wrox Programmer Forums
|
BOOK: Professional JavaScript for Web Developers 2nd edition ISBN: 9780470227800
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers, 2nd Edition by Nicholas C Zakas; ISBN: 9780470227800
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers 2nd edition ISBN: 9780470227800 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2010, 05:10 PM
Registered User
 
Join Date: Jul 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Type coercion issue

On Page 60 section entitled 'Equal and Not Equal'

When performing conversions it states the following:

'If one operand is a string and the other is a number, attempt to convert the string into a number before checking for equality.'

Yet on page 482 in the first example given as follows:

alert(5 == "5")
alert(5 === “5”);

The explanation in the following paragraph states:

'In this code, the number 5 and the string “5” are compared using the equal operator and the identically equal operator. The equal operator first converts the number 5 into the string “5” and then compares it with the other string “5”, resulting in true.'

Page 60 clearly states that under such circumstances a string is converted into a number before checking for equality, but the opposite is being stated in the example on page 482, so the question is which is correct?

Last edited by Mikeos; September 9th, 2010 at 05:12 PM..
 
Old September 9th, 2010, 07:57 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Page 60 is correct.
__________________
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion from type 'DBNull' to type 'Boolean' is not valid. alcsew ASP.NET 2.0 Basics 1 October 24th, 2009 09:42 PM
Conversion from type 'DBNull' to type 'String' is not valid. phuc2583 ASP.NET 3.5 Professionals 4 October 1st, 2009 09:46 AM
Issue with SqlData Type in ASP.NET snejsnej ASP.NET 1.0 and 1.1 Professional 1 August 30th, 2006 04:47 PM
type issue m3rajk Beginning PHP 3 August 6th, 2003 05:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.