JS generates 26 uppercase and lowercase letters

Source: Internet
Author: User
Tags uppercase letter

Mainly used in the Str.charcodeat () and String.fromCharCode () methods

--"Use charCodeAt () to get the Unicode encoding of a specific character in a string.

--"fromcharcode () can accept one (or more) specified Unicode values and return the corresponding string.

//generates an uppercase letter A with a Unicode value offunctiongeneratebig_1 () {varstr = [];  for(vari=65;i<91;i++) {Str.push (String.fromCharCode (i)); }    returnstr;}//generates a Unicode value of uppercase afunctionGeneratesmall_1 () {varstr = [];  for(vari=97;i<123;i++) {Str.push (String.fromCharCode (i)); }    returnstr;}//Convert a string to a Unicode codefunctionTounicode (str) {varCodes = [];  for(vari=0;i<str.length;i++) {Codes.push (Str.charcodeat (i)); }    returncodes;}functionGeneratesmall () {varCh_small = ' a '; varStr_small = ' ';  for(vari=0;i<26;i++) {Str_small+ = String.fromCharCode (ch_small.charcodeat (0) +i); }    returnStr_small;}functionGeneratebig () {varCh_big = ' A '; varStr_big = ' ';  for(vari=0;i<26;i++) {Str_big+ = String.fromCharCode (ch_big.charcodeat (0) +i); }    returnStr_big;} Console.log (Generatebig ()); Console.log (Generatesmall ()); Console.log (Tounicode (Generatebig ())); Console.log ( Tounicode (Generatesmall ())); Console.log (generatebig_1 ()); Console.log (Generatesmall_1 () );

Can get results--"

Where fromCharCode plays a significant role in the conversion of HTML entity characters, see above

JS generates 26 uppercase and lowercase letters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.