Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing value not a reference
Message
From
21/03/2016 05:50:38
 
 
To
20/03/2016 21:21:20
General information
Forum:
Javascript
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01633405
Message ID:
01633412
Views:
45
>In this line:
>
>
>   oDiv.onmouseout=function(e) {OnMouseOut(e,tcAlignID,lnLeft,lnTop,lnWidth,lnHeight)}
>   lnLeft=lnLeft-tnAlignOffsetLeft
>   lnTop=lnTop-tnAlignOffsetTop
>
>
>The values of lnLeft and lnTop, for example, are passed by reference.
>
>However, once the event is triggered, the value is not what was passed but the adjusted value in the lines following.
>
>What would be the best approach to pass a variable value?

Integers are passed by value (I'm assuming lnLeft/lnTop *are* integers) so something else must be going on.
e.g:
                 var i = 5;
                  oDiv.onmouseout = function(e) {
                      OnMouseOut(e, i);
                      alert("After"+i); // 5
                  };
                  
 
                  function OnMouseOut(e, i) {
                      i = i + 1;
                  }
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform