Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Professional JavaScript for Web Developers 3rd edition
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 31st, 2012, 01:28 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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".
Reply With Quote
  #2 (permalink)  
Old December 12th, 2012, 01:26 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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")
Reply With Quote
  #3 (permalink)  
Old December 12th, 2012, 01:46 AM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What version of FF were you using?
Reply With Quote
  #4 (permalink)  
Old December 12th, 2012, 06:50 PM
Registered User
Points: 9, Level: 1
Points: 9, Level: 1 Points: 9, Level: 1 Points: 9, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.'
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 04: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



All times are GMT -4. The time now is 10:04 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.