1、charAt():把字符串分成每一个字符,从左往右提取指定位置的字符

var str = '天气';
alert( str.charAt(1) );            //气

2、charCodeAt ():在第一个的基础上,返回的是字符的unicode编码

var str = '天气';
 
alert( str.charCodeAt(0) );        //22825

3、String.fromCharCode():通过编码值在unicode编码库中查找出对应的字符。

alert( String.fromCharCode(22825, 27668) );            //天气

4、当两个字符串进行大小比较时,比的是第一个字符的unicode编码的大小:

alert( 'abbbbb' > 'b' );                //unicode编码中a<b,所以是false;
alert( '10000' > '2' );                 //unicode编码中1<2,所以是false;

  

相关文章:

  • 2021-09-26
  • 2021-08-02
  • 2022-12-23
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案