Wrox Programmer Forums
| 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 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
  #1 (permalink)  
Old January 11th, 2006, 11:18 AM
jminatel's Avatar
Wrox Staff
Points: 17,906, Level: 58
Points: 17,906, Level: 58 Points: 17,906, Level: 58 Points: 17,906, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Location: Indianapolis, IN, USA.
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 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, WROX - A Wiley Brand
Did someone here help you? Click on their post!
  #2 (permalink)  
Old January 30th, 2013, 07: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


Similar Threads
Thread Thread Starter Forum Replies Last Post
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 05: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 04:06 PM





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