为你而来

2012年3月11日

javascript: 面向对象基础知识

摘要: funtiont person(){ this.name=''; this.sex=''; this.run=_run; function _run() { }}p=new person();for(x in p){ //x为属性或方法名; //用p[x]获取属性的值 //或者eval("p."+x)亦可 typeof mobile[x] == "function"}p.weight=45;//这样即增加了weight属性delete p.name;//这样便删除了name属性 阅读全文

posted @ 2012-03-11 20:18 为你而来 阅读(118) 评论(0) 推荐(0) 编辑

javascript:字符串对象

摘要: str=new String('这是一个字符串对象');str=string(23);str.replace(search,replace);str.indexOf();str.lastIndexOf();str.charAt(0);str.substring(index1,index2);//从index1到index2前的字符串str.substr(start,length);//start为负数,在ie浏览器中是不起作用的str.slice(index1,index2);str='hello'str.slice(-3,4)//从倒数第三个 到正数(下标从0 阅读全文

posted @ 2012-03-11 03:20 为你而来 阅读(138) 评论(0) 推荐(0) 编辑

导航