why are two scenarios different? what I want is the first script, but in the second drawData () it modifies the data, this is strange. can someone tell me why this is so and how to fix it. thank!
var data = ["right"] ;
function drawData(arrs,type){
if(type=="percentage"){
arrs[0]="omg";
}
alert(data[0]);
}
drawData(data);
drawData(data,"percentage");
second:
var data = "right" ;
function drawData(arrs,type){
if(type=="percentage"){
arrs="omg";
}
alert(data);
}
drawData(data);
drawData(data,"percentage");
source
share