Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 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 January 11th, 2006, 10:18 AM
jminatel's Avatar
Wrox Staff
Points: 13,738, Level: 50
Points: 13,738, Level: 50 Points: 13,738, Level: 50 Points: 13,738, Level: 50
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Location: Indianapolis, IN, USA.
Posts: 1,832
Thanks: 52
Thanked 100 Times in 79 Posts
Default book related questions here

Don't forget, this particular forum exists mainly to discuss the book Professional JavaScript for Web Developers. Fair game includes anything that you can't understand, think doesn't work right, or even "why does it work this way" related to something specific in the book. General "how do I do this with JavaScript" questions posted here might get answered but they might not. Your best bet for non-book JavaScript "how do I" questions however is in the "JavaScript How-To" forum here at:
http://p2p.wrox.com/javascript-how-87/

Thanks for your participation.

Jim Minatel
Senior Acquisitions Editor
Wiley Technology Publishing
WROX Press
Blog: http://wroxblog.typepad.com/
Jim's Book of the week: No book this week - Donate to the Red Cross!
__________________
Jim Minatel
Associate Publisher
Wiley Technology Publishing
WROX Press
Blog: http://p2p.wrox.com/content/blogs/jminatel
Wrox online library: http://wrox.books24x7.com
Wrox on Twitter: http://twitter.com/wrox
Did someone here help you? Click on their post!
Reply With Quote
  #2 (permalink)  
Old January 30th, 2013, 06:52 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing References

Confused...in the book page 88-89 you make reference to passing references is actually being passed by value; however, the code that is used to prove this does not make since to me. Inside the function setName(obj) you are creating a new Object reference, which in other languages would say this is a local variable and will die at the end of the function, thus not reflecting a change on the Object created outside the function. Here is a couple of examples:
HTML Code:
        var person = new Object();
	
	person.name = 'John';
	
	console.log(person.name);
	
	function changeName(obj){
		obj = new Object();
		obj.name = 'Nick';
		return obj.name;
	}
	
	console.log(changeName(person));
	console.log(person.name);
This example produces: John, Nick, John
HTML Code:
        var person = new Object();
	
	person.name = 'John Doe';
	
	console.log(person.name);
	
	function changeName(obj){
		// obj = new Object(); comment out
		obj.name = 'Nick';
		return obj.name;
	}
	
	console.log(changeName(person));
	console.log(person.name);
This example, commenting out the creation of a new Object inside the function, produces: John, Nick, Nick

Which suggest to me that it was in fact passed by reference and not by value.

Any further clarity on this would be appreciated.

Regards,

Darren
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
finding free book "Beginning Jsp Book" ruzdi JSP Basics 0 December 7th, 2007 12:46 PM
2 related questions on Graphs Mr.Pickles Excel VBA 1 July 22nd, 2007 10:35 AM
Forum Purpose: Book questions only please jminatel BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 0 February 26th, 2007 04:23 PM
Book related questions here jminatel BOOK: Professional Ajax ISBN: 978-0-471-77778-6 0 September 27th, 2006 11:02 AM
using the book and the related website psykik ASP.NET 2.0 Basics 1 February 14th, 2006 03:06 PM



All times are GMT -4. The time now is 04:02 PM.


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