SOURCE

//字符串的调用
var a="welcome";
 document.write(a.charAt(2) + "<br/>");
 document.write(a.charAt(6) + "<br/>");
 document.write(a.substring(3) + "<br/>");
 document.write(a.substring(0,2) + "<br/>");
 //换字符
 var b="Behind bad luck comes good luck"
 document.write(b+"</br>");
 document.write(b.replace("bad","good")+"</br>");
 document.write(b.replace(/good/g,"good")+"</br>");
 document.write(b+"</br>");
 document.write(b.split("")+"</br>");
 document.write(b.split(" ")+"</br>");
 document.write(b.split(".")+"</br>");
 //查询字的位置
 document.write(b+"</br>");
 document.write(b.indexOf("Behind")+"</br>");
 document.write(b.lastIndexOf("comes")+"</br>");
 document.write(b.match("good")+"</br>");
 document.write(b.match(/good/g)+"</br>");
 document.write(b.search(/good/g)+"</br>");
 //找出所有a的个数,不区分大小写。 
 function countChar(stringToCount, char) {
    var charCount = 0;
        for(var i=0;i<stringToCount.length;i++)
        {
            var char = stringToCount.charAt(i);
            if (char.toLowerCase() == "a") {
                charCount += 1;
            }
        }
    return charCount;
}
var stringToCount = "A young idler,an old beggar";
document.write("There are " + countChar(stringToCount, "a") + " a in " + stringToCount); 
function writeDocument(variable) {
    document.write(variable + "<br/>");
} 
var a=["HTML","CSS","JavaScript","jQuery","Vue.js" ];
 document.write(a + "<br/>");
 document.write(a[2] + "<br/>");
 a[3]="hello";
 a[5]="you";
 a[8]="me";
  document.write(a + "<br/>");
console 命令行工具 X clear

                    
>
console