Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Professional JavaScript for Web Developers 3rd edition
|
BOOK: Professional JavaScript for Web Developers 3rd edition
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers, 3rd Edition by Nicholas C Zakas; ISBN: 978-1-1180-2669-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers 3rd edition 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 May 31st, 2012, 01:28 AM
Registered User
 
Join Date: May 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 3, (40p) parseInt("070") returns 56 not 0 in ECMAScript5

In chapter 3 (40p), discussion of parseInt() function, the book reads like following:

//56 (octal) in ECMAScript 3, 0 (decimal) in ECMAScript 5
var num = parseInt("070");


I tried this in my firefox browser, like following:

<script type="text/javascript">
"use strict";

var a = parseInt("070");
console.log(a); // 56
</script>


I can' sure this is error or common quirks, or maybe I don' know something important. If I'm wrong, how can I force the browser to use ECMA 5?

-----------------------

and the succeeding description, the book reads like this:

In ECMAScript 5 JavaScript engines, the ability to parse octal values has been removed from parseInt() so the leading zero is considered invalid and the value is treated the same as “0”, resulting in the decimal value 0.

What I don' understand is that, if the engine removed octal conversion, then shouldn' it convert the literal as if it were decimal, so that parseInt("070") should return "70"?. I think that makes sense.

so.. I hope some clearer discussion so I understand why parseInt('070') in ECMA 5 should return "0".
 
Old December 12th, 2012, 02:26 AM
Registered User
 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried this in Chrome 23.0.1271.95 and IE 10 and got 70 in both. (with & without "use strict")
 
Old December 12th, 2012, 02:46 AM
Registered User
 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What version of FF were you using?
 
Old December 12th, 2012, 07:50 PM
Registered User
 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I contacted the author about this and this was his response:

'Yup, that is a typo. In ECMAScript 5, "070" is treated the same as "70".

There is an errata page on the Wrox site, but for some reason they've not been updating it. I've contacted them several times asking when it will be updated, and the only response I've received is, "soon". I apologize for this, I know that can be incredibly frustrating as a reader (it's also very frustrating as an author). I'll ping them again today.'





Similar Threads
Thread Thread Starter Forum Replies Last Post
not like the book in "Chaper 11"-"Ex11_01" Louaih83 BOOK: Ivor Horton's Beginning Visual C++ 2010 0 April 2nd, 2012 09:38 PM
MSXSL gives error message for "for" inside "select" ilyaz XSLT 1 December 9th, 2010 05:02 PM
How to theme the "Browse" button of "FileUpload" control? varunbwj BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 01:22 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM





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