惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Palo Alto Networks Blog
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
L
Lohrmann on Cybersecurity
有赞技术团队
有赞技术团队
The GitHub Blog
The GitHub Blog
C
Cisco Blogs
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
Simon Willison's Weblog
Simon Willison's Weblog
T
Tenable Blog
Know Your Adversary
Know Your Adversary
Spread Privacy
Spread Privacy
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
I
InfoQ
D
Darknet – Hacking Tools, Hacker News & Cyber Security
W
WeLiveSecurity
Hacker News - Newest:
Hacker News - Newest: "LLM"
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
Attack and Defense Labs
Attack and Defense Labs
罗磊的独立博客
T
The Exploit Database - CXSecurity.com
I
Intezer
GbyAI
GbyAI
Jina AI
Jina AI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Google Online Security Blog
Google Online Security Blog
Engineering at Meta
Engineering at Meta
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
小众软件
小众软件
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
Project Zero
Project Zero

博客园 - ★金★

导出EXCEL table变宽格式 IE11兼容性设定 C#获取多个相同name值 DIV左右行 Jquery绑定Select下拉菜单 SQL中多项合并时请加ISNULL Repeater中绑定下拉菜单的2种方法 WebForm设置URL路由后要照顾好之前的连接 Repeater中获取HTML select 值 NPOI生成Excel 博文阅读密码验证 - 博客园 Firefox中不支持parentElement用parentNode取代 jquery给span赋值的时候出现firefox不兼容 jquery表单验证增加确认及可选不需要验证的方法 display和visibility的区别 SQL中Replace替换引号 javascript动态添加删除行后行内计算及取值 取代RadioButtonList及RadioButton方法
javascript可用数组取代case格式化字符
★金★ · 2011-04-08 · via 博客园 - ★金★

这种方式代码更简洁:

    function getTypes(classid) {
        
var types = [];
        types[
"1"= "R";
        types[
"2"= "S";
        types[
"3"= "D";
        types[
"4"= "C";
        types[
"5"= "F";
        types[
"6"= "H";
        
return types[classid];
    }

可对比swich,case的方法:

    function getTypes(classid) {
    
var str="";
    
switch(classid)
    {
        
case "1":
            str 
= "R";
            
break;
        
case "2":
            str 
= "S";
            
break;
        
case "3":
            str 
= "D";
            
break;
        
case "4":
            str 
= "C";
            
break;
        
case "5":
            str 
= "F";
            
break;
        
case "6":
            str 
= "H";
            
break;
        
default:
            str 
= "";
            
break;
    }
    
return str;
     } 

posted on 2011-04-08 17:36  ★金★  阅读(268)  评论()    收藏  举报