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 />");