摘要: min()和max()var max=Math.max(3,54,32,16);alert(max);//54var min=Math.min(3,54,32,16);alert(min);//3ceil(),floor(),round()alert(Math.ceil(25.9));//26alert(Math.ceil(25.5));//26alert(Math.ceil(25.1));//26alert(Math.round(25.9));//26alert(Math.round(25.5));//26alert(Math.round(25.1));//25alert(Math.floo 阅读全文
posted @ 2013-11-27 21:15 PiLee 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Global(全局)对象1.URI编码方法2.eval()方法eval()放大就像是一个完整的ECMAScript解析器,它只接受一个参数,即要执行的ECMAScript(或JavaScript)字符串eval("alert('hi')");等价于alert("hi");eval()之星的代码可以引用在包含环境中定义的变量var msg="hello world";eval("alert(msg)");//"hello world"4.window对象Web浏览器都是将这个全局对 阅读全文
posted @ 2013-11-27 21:04 PiLee 阅读(141) 评论(0) 推荐(0) 编辑
摘要: String 类型是字符串的对象包装类型var stringObjiect = new String("hello world");String 类型的每个实例都有一个length属性,表示字符串中包含多个字符var stringValue="hello world";alert(stringValue.length);//"11"注意,即使字符串中包含双字节,每个字符也仍然算一个字符。1.字符方法两个用于访问字符串中特定字符的方法是charAt()和charCodeAt()var stringValue="hello wo 阅读全文
posted @ 2013-11-27 19:07 PiLee 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 每个函数都包含两个属性:length和prototype其中length属性表示希望接收的命名参数的个数function sayName(name){alert(name);}function sum(num1,num2){return num1+num2;}function sayHi(){alert("hi");}alert(sayName.length);//1alert(sum.length);//2alert(sayHi.length);//0sayName()函数定义了一个参数,因此length的属性值为1sum()定义了两个所以为2,而sayHi()没有定义所 阅读全文
posted @ 2013-11-27 14:36 PiLee 阅读(326) 评论(0) 推荐(0) 编辑
摘要: arguments.callee 消除耦合现象例子function factorial(num){if(num<=1){return 1;}else{return num*arguments.callee(num-1) //arguments保存函数参数,callee是个指针,指向拥有这个arguments对象的函数}}在这个重写够的factorial()函数的函数体内,没有再引用函数名factorial。这样无论函数使用时使用的是什么名字,都可以保证正常完成递归调用。函数内部另一个特殊对象是this.this引用的是函数据以执行的环境对象——或者可以说是this值(当在网页的全局作用域 阅读全文
posted @ 2013-11-27 14:27 PiLee 阅读(121) 评论(0) 推荐(0) 编辑