将字符串全部转换成小写
let hisName = 'JOPLLLLLDssss';
console.log('name',hisName.toLocaleLowerCase())
//name jopllllldssss
console.log('name',hisName.toLowerCase())
将字符串全部转换成大写
console.log('name',hisName.toLocaleUpperCase())
//name JOPLLLLLDSSSS
console.log('name',hisName.toUpperCase())
利用loadsh实现
<script src="lodash.js"></script>
$ npm i -g npm
$ npm i --save lodash
var _ = require('lodash');
将字符串全部转换成小写
//转换字符串string以空格分开单词,并转换为小写。
_.lowerCase(hisName);
//转换整个string字符串的字符为小写
_.toLower(hisName)
将字符串全部转换成大写
//转换字符串string为 空格 分隔的大写单词。
_.upperCase(hisName)
//转换整个string字符串的字符为大写
_.toUpper(hisName)
首字母大写
_.upperFirst(hisName)