Knowledge Walls
John Peter
Pune, Maharashtra, India
How to use call by value in Javascript functions with Example
3245 Views
HTML
<div><b>How to use call by value in Javascript functions with Example</b></div>
<div>Values are not swaped in this eample because it is call by value</div>
<br />
JAVASCRIPT
function swap(num1,num2){
    num = num1;
    num1 = num2;
    num2 = num;
}

var num1 = 12;
var num2 = 24;

document.write(num1+" - "+num2+"<br />");
swap(num1,num2);
document.write(num1+" - "+num2+"<br />");
Demo & Output 
Best Lessons of "Good Javascript Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details