标签:blog http color java io strong 数据 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 //解除引用
javascript小白学习指南1---0,布布扣,bubuko.com
标签:blog http color java io strong 数据 for
原文地址:http://blog.csdn.net/tomihaohao/article/details/38497155