Skip to content

Instantly share code, notes, and snippets.

@jikeytang
Created July 31, 2014 15:37
Show Gist options
  • Save jikeytang/484433779f3d7f88e782 to your computer and use it in GitHub Desktop.
Save jikeytang/484433779f3d7f88e782 to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140801-题目1
请问JS怎么判断中文,数字,字母?
PS:
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。
```javascript
// you code
```
2. 粘贴代码时请使用shift+tab,缩进前面的空白。
@chriswenwu
Copy link

function testS(str){
                if(typeof str=="number"){
                    return "数字";
                }
                if(str.charCodeAt(0)>256){
                    return "中文字符串";
                }
                if(str.charCodeAt(0)<=256){
                    return "字母";
                }
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment