JavaScript generates uppercase and lowercase letters _javascript tips

Source: Internet
Author: User
Tags lowercase

Mainly used to Str.charcodeat () and String.fromCharCode () method

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

--fromCharCode () can accept one (or more) of the specified Unicode value, and then return the corresponding string.

The Unicode value for the generated uppercase A is the Generatebig_1 function () {var str = [];
  for (Var i=65;i<91;i++) {Str.push (String.fromCharCode (i));
return str;
  The Unicode value for uppercase A is generated as the Generatesmall_1 function () {var str = [];
  for (Var i=97;i<123;i++) {Str.push (String.fromCharCode (i));
return str;
  //Convert string to Unicode code function tounicode (str) {var codes = [];
  for (Var i=0;i<str.length;i++) {Codes.push (Str.charcodeat (i));
return codes;
  function Generatesmall () {var ch_small = ' a ';
  var str_small = ';
  for (Var i=0;i<26;i++) {Str_small + = String.fromCharCode (ch_small.charcodeat (0) +i);
return str_small;
  function Generatebig () {var ch_big = ' A ';
  var str_big = ';
  for (Var i=0;i<26;i++) {Str_big + = String.fromCharCode (ch_big.charcodeat (0) +i);
return str_big;
} console.log (Generatebig ());

Console.log (Generatesmall ());
Console.log (Tounicode (Generatebig ()));

Console.log (Tounicode (Generatesmall ()));
Console.log (Generatebig_1 ()); COnsole.log (Generatesmall_1 ());

 

But the result--"

Where fromCharCode plays a big role in HTML entity-character conversions

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.