美文网首页
2018-03-13

2018-03-13

作者: mo_陌上花开 | 来源:发表于2018-03-13 19:38 被阅读0次

计算字符串的长度

var text = "hollow world"

document.write(text.length)

//代码运行的结果

使用字符串对象的toUpperCase()方法将字符串转换为大写

var text = "hollow world"

document.write(text.toUpperCase())

//代码运行结果

indexOf()使用方法  如何使用 indexOf() 来定位字符串中某一个指定的字符首次出现的位置

var str = "hollow world"

document.write(str.indexOf("w")+"<br/>")

document.write(str.indexOf("world"))

//代码运行结果

相关文章

网友评论

      本文标题:2018-03-13

      本文链接:https://www.haomeiwen.com/subject/mnhtqftx.html