字符串操作是所有编程语言的基本,如果字符串类型对象的操作和理解不够熟练,那么将很难进展编程工作,对字符串类型得心应手的操作是编程更上一层楼的基础!
此文章总结梳理JS中常用的几个方法.
var str = 'hello world!';
toUpperCase()
将小写字母转换成大写字母,其返回值为大写;
var str2 = str.toUpperCase();
console.log(str2);
//输出 HELLO WORLD!
toLowerCase()
将大写字母转换成小写字母,其返回值为小写;
var str2 = str.toLowerCase();
console.log(str2);
//输出 hello world!
...