SOURCE

function writeDocument(variable) {
    document.write(variable + "<br/>");
} 

var wel="Welcome";


writeDocument(wel);
writeDocument(wel.length);
writeDocument(wel.toLowerCase());
writeDocument(wel.toUpperCase());
writeDocument(wel.charAt(2));
writeDocument(wel.charAt(6));
writeDocument(wel.substring(3));
writeDocument(wel.substring(0,2));

var sen="We have fun in our class.Do you enjoy your class"
writeDocument(sen);
writeDocument(sen.replace("We","You"));
writeDocument(sen.replace(/class/g,"programming class"));

var spl="We have fun in our class"
writeDocument(spl);
writeDocument(spl.split(" "));
writeDocument(wel);
writeDocument(wel.split(""));
writeDocument(sen.split(""));

writeDocument(sen.indexOf("class"));
writeDocument(sen.lastIndexOf("class"));
writeDocument(sen.match("class"));
writeDocument(sen.match(/class/g));
writeDocument(sen.search(/class/g));

var c="Can you can a can as a Canner can can a can"

function count(str,char)
{   var count=0;
    for(var i=0;i<str.length;i++)
    {
        var ca=str.charAt(i);
        if(ca.toLowerCase()==char)
        {
            count++;
        }
    }
    document.write(count + "<br/>");
}

count(c,"c");
console 命令行工具 X clear

                    
>
console