cocos2d-js中String对象的常用方法
一、JavaScript中String对象常用的函数总结
var str = new String("Tony Guan"); //或者 var str = "Tony Guan"
console.log(str.length); //9
console.log(str.toUpperCase()); //TONY GUAN
console.log(str.toLowerCase()); //tony guan
console.log(str.charAt(0)); //T
console.log(str.indexOf('n')); //2
console.log(str.lastIndexOf('n')); //8
console.log(str.substring(5,9)); //Guan
console.log(str.split(" ")); //['Tony','Guan']