09 2013 档案
图解JS的传值与传址
摘要://编程过程中经常会碰到传值,传址的问题!今天的主题就是关于传值、与传址。//先讲讲赋值操作//下例是原始类型赋值操作var a=1,b=a,a=2;console.log("a="+a+",b="+b);//a先是被赋值为1,接着把a的值赋给b, 这时会进行值的拷贝,因此b=1;然后又把a赋值为2.//在没有执行a=2之前,我们试试下列代码:console.log(a===b); //输出为true. 可见它们在内存中是指向同一个位置的。//下例是引用类型赋值操作var aTest1=['Dylan',"Tong", 阅读全文
posted @ 2013-09-30 18:30 idylan 阅读(2739) 评论(1) 推荐(0)
JavaScript数据类型检测详解
摘要://JS该如何检测数据的类型呢?//使用关键字: typeof //输出结果依次为:'number','string','boolean'.1 console.log(typeof 17);2 console.log(typeof '17');3 console.log(typeof true);//输出结果依次为:'object','undefined'1 console.log(typeof null);2 console.log(typeof undefined);//可知:null 是obj 阅读全文
posted @ 2013-09-28 16:26 idylan 阅读(1315) 评论(2) 推荐(0)
JS之For---in 语句
摘要:下面说一下for… in语句。可直接把下面的代码复制到浏览器的控制台或Node环境下去执行。~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//用来快速迭代对象。var o ={name:'dylan',age:24,num:110};for(var test in o){ console.log("o["+test+"]= "+o[test]);}console.log("~~~~~~~~~~~")Object.prototype.getName =function(){return this.n 阅读全文
posted @ 2013-09-26 20:36 idylan 阅读(2795) 评论(2) 推荐(1)