在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Math对象
常用属性
常用方法
Math.random()
字符串方法length属性
var str = "Hello World!!!"; var result = str.length; console.log(result); charAt()
var str = "Hello World!!!"; var result = str.charAt(6); console.log(result); charCodeAt()
var str = "Hello World!!!"; var result = str.charCodeAt(6); console.log(result); fromCharCode()
var result = String.fromCharCode(18888); console.log(result); concat()
var str = "Hello World!!!"; var result = str.concat("你好","世界"); console.log(result); indexOf()
var str = "Hello World!!!"; var result0 = str.indexOf('l'); var result1 = str.indexOf('l',3);//从第三个位置开始找 var result2 = str.indexOf('l',5);//从第五个位置开始找 console.log(result0); console.log(result1); console.log(result2); lastIndexOf()
slice()
var str = "Hello World!!!"; var result0 = str.slice(0,2); var result1 = str.slice(1,-4); console.log(result0); console.log(result1); substring()
var str = "Hello World!!!"; var result0 = str.substring(0,2); console.log(result0); split()
var str = "He llo Worl d!!!"; var result0 = str.split(' '); console.log(result0); console.log(Array.isArray(result0)); toUpperCase()
var str = "He llo Worl d!!!"; var result0 = str.toUpperCase(); console.log(result0); toLowerCase()
var str = "He llo Worl d!!!"; var result0 = str.toLowerCase(); console.log(result0); 总结
|
请发表评论