please dont rip this site

Language Java Script Definitive Examples 9.1.TXT

//  This example is from the book _JavaScript: The Definitive Guide_.    
// Written by David Flanagan.  Copyright (c) 1996 O'Reilly & Associates.
// This example is provided WITHOUT WARRANTY either expressed or implied.
// You may study, use, modify, and distribute it for any purpose.        

// First we illustrate copy by value
n =index.html 1;            // variable n holds the value 1
m = n;            // copy by value:  variable m holds a distinct value 1

// Here's a function we'll use to illustrate pass-by-value.
// As we'll see, the function doesn't work the way we'd like it to.
function add_to_total(total, x)
{
    total = total + x;  // this line only changes the internal copy of total
}

// Now call the function, passing the numbers contained in n and m by value.
// The value of n is copied, and that copied value is named total within the
// function.  The function adds a copy of m to that copy of n.  But adding
// something to a copy of n doesn't affect the original value of n outside
// of the function.  So calling this function doesn't accomplish anything.
add_to_total(n, m);

// Now, we'll look at comparison by value.  
// In the line of code below, the literal 1 is clearly a distinct numeric
// value encoded in the program.  We compare it to the value held in variable
// n.  In comparison by value, the bytes of the two numbers are checked to
// see if they are the same.
if (n == 1) m = 2;      // n contains the same value as the literal 1.


file: /Techref/language/java/script/definitive/examples/9.1.txt, 1KB, , updated: 1997/4/4 11:59, local time: 2024/6/27 11:09,
TOP NEW HELP FIND: 
3.136.25.35:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://piclist.com/techref/language/java/script/definitive/examples/9.1.txt"> language java script definitive examples 9</A>

Did you find what you needed?

  PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .