js大小写字母互相转换

2025年02月28日 建站教程

javascript如何利用函数实现大写字母转换成小写字母(小写字母转换成大写字母),下面web建站小编给大家详细介绍一下实现代码!

利用toUpperCase()方法把字符串转换为大写

let str = 'Hello web'
console.log('转换:', str.toUpperCase())
//转换: HELLO WEB

利用toLocaleUpperCase()方法把字符串转换为大写

let str = 'Hello web'
console.log('转换:', str.toLocaleUpperCase())
转换: HELLO WEB

利用toLowerCase()方法把字符串转换为小写

let str = 'Hello web'
console.log('转换:', str.toLowerCase())
转换: hello web

利用toLocaleLowerCase()方法把字符串转换为小写

let str = 'Hello web'
console.log('转换:', str.toLocaleLowerCase())
转换: hello web

本文链接:http://so.lmcjl.com/news/24030/

展开阅读全文
相关内容