【轉】JS字符(字母)與ASCII碼轉換方法

var strVariable;
for(var i=0;i<25;i++)
{
    console.log(String.fromCharCode((65+i)));
}

strVariable.toUpperCase( ); //轉大寫
strVariable.toLowerCase( ); //轉小寫
//字符轉ascii碼:用charCodeAt();
//ascii碼磚字符:用fromCharCode();
//大寫字母A 到Z 的值是從65 到90;
//小寫a到z 是從91 到 122;
//如:

  str="A";
  code = str.charCodeAt();//65
  str2 = String.fromCharCode(code);//A
  str3 = String.fromCharCode(0x60+26);//Z

 轉自:https://www.cnblogs.com/mingrn/p/8064082.htmljavascript

相關文章
相關標籤/搜索