随笔分类 -  js

摘要:// 判断是否存在中文字符function checkChinese(obj){ if(/.*[\u4e00-\u9fa5]+.*$/.test(obj)) { return true ; } return false ; } 阅读全文
posted @ 2013-10-13 15:13 eyotata 阅读(244) 评论(0) 推荐(0)
摘要:正则转义字符: Table 10-2. Regular expression character classesCharacter Matches[...] Any one character between the brackets.[^...] Any one character not between the brackets.. Any character except newline or another Unicode line terminator.\w Any ASCII word character. Equivalent to [a-zA-Z0-9_].\W Any ch. 阅读全文
posted @ 2013-08-17 20:04 eyotata 阅读(528) 评论(0) 推荐(0)
摘要:String.prototype.trim = String.prototype.trim || function () {if (!this) return this;//Don't alert the empty string/* this.replace(/^\s+|\s+$/g, "") 和 this.replace(/^\s+/,'').repalce(/\s+$/,'');相比.后者比前者快150ms左右,如果字符串更长可能差距会更大,所以决定使用高效的方法*/this.replace(/^\s+/, '' 阅读全文
posted @ 2013-08-17 19:58 eyotata 阅读(195) 评论(0) 推荐(0)
摘要:Closure: JavaScript词缀作用域。javascript的函数在执行时是按照定义作用域链起作用。内嵌函数f()被包含在一个作用域链中,在这个作用域链中scope被赋值为"local scope"。无论f最终在哪里被执行,这种绑定一直存在。var scope = "global scope";function checkscope() { var scope = "local scope"; function f() { return scope; } return f;}console.log(checkscope()( 阅读全文
posted @ 2013-08-11 21:18 eyotata 阅读(317) 评论(0) 推荐(0)
摘要:1 2 3 4 5 21 83 84 85 86 87 hello world88 89 注意:在if()判断体内自动转为false的是:0,'',undefined,null,NaN。而' ','0'在if()判断体中为true90 91 92 阅读全文
posted @ 2013-08-09 11:22 eyotata 阅读(336) 评论(0) 推荐(0)
摘要:用户 密码 阅读全文
posted @ 2012-06-12 15:46 eyotata 阅读(216) 评论(0) 推荐(0)