标签:blog http io color ar 使用 java sp for
var csdn = new Object(); csdn.blog = "Tomihaohao"; alert(csdn.blog) // Tomihaohao var name ="csdn"; name.age = 123; alert(name.age) //undefined //相同的一段方式的代码为什么 结果不一样呢?
var a =1; var b = a; alert(b); //------------------------------------- var obj1 = new Object(); var obj2 = obj1; obj1.name = "csdn"; alert(obj2.name) //"csdn" //知道上面两段代码在解析器里发生什么了吗?
function addnum(param){ num +=10; return num; } var a = 10; var b = addnum(a); alert(a); //10 alert(b); //20 //看 他们两个是互不影响的
function setObj(obj){ obj.name = "csdn"; obj = new Object(); obj.name = "Tomihaohao" } var T = new Object(); setObj(T); alert(T.name); //是什么呢? 没错依旧是csdn //实际上这个局部对象,在函数运行完后就被kill了
var person = [] alert(person instanceof Array) //person 是 Array对象吗? 当然是!
var color = "white"; function changeColor(){ var anotherColor = "red"; function swapColors(){ var tempColor = anotherColor; anotherColor = color; color = tempColor; //这里能够訪问 color anotherColor tempColor } swaoColors(); //这里能够訪问color anotherColor } changeColor(); //仅仅能訪问到color
for(var i =0 ;i<10;i++) { console.log(i); } alert(i); //i=10
var color ="blue"; function getColor(){ //var volor ="red"; return color; } alert(getColor()) //blue //假设去掉 getColor()中的凝视 那么返回的就是red
//向这样 var a ="csdn "; //没用啦 a = null //解除引用
标签:blog http io color ar 使用 java sp for
原文地址:http://www.cnblogs.com/gcczhongduan/p/4089214.html