jsString common properties and methods

  <script>
fu = function(name){
this.name = name;
};
fu.prototype.sex = 'male';

var b = new fu('ls');
fu.prototype.age = '24';
document .write(b.constructor+"<br/>"); //Return what the example generated by
var f = [1,2,3,4];
var h = [7,8];
document.write(f. concat(h)+"<br/>");//Connection string or array
document.write(b.sex+"<br/>");//Add property to object
document.write(b.age+"< br/>");
            document.write(String.fromCharCode(65, 66, 67) + "<br/>");//fromCharCode The static method of String returns the corresponding string according to the unicode value. Support multiple returns
            var a = "hellow Hellow World";
            document.write(a.charAt(8) + "<br/>"); // Output the character at the specified position. just one
            document.write(a.charCodeAt('9') + "<br/>");//Output the unicode encoding of the specified character. Only one
            document.write(a.indexOf('o') + "<br/>");//The first occurrence of the string
            document.write(a.lastIndexOf('o') + "<br/>") ;//The last occurrence of the string
            document.write(a.match('hellow') + "<br/>");//Match the string. Matches to the output string as-is. Ca n't match the output null
            document.write(a.replace(/hellow/g, 'start') + "<br/>");//Replace hellow with start g to enable global replacement
            document.write(a.search (/Hellow/i) + "<br/>");//Does the search string contain Hellow, if so, return the first occurrence of Hellow. Returns -1 if not included; i is to enable case-insensitive mode.
            var c = new Array();
            c[0] = 'name';
            c[1] = 'xrx';



            c[5] = 24;
            var fn = new Boolean(false);
            document.write(c.slice(2,5) + "<br/>");//Select the specified elements to form a new array. Print sex, male; can be understood as greater than or equal to 2, less than 4. Select subscript 2,3
            document.write(a.substring(2,5)+"<br/>");//Intercept the string. Support from left to right. Intercept from 2 to before 5
            document.write(a.substr(2,3)+"<br/>");//From 2, intercept three characters
            document.write(fn.valueOf()+"< br/>");//Return the initial value of boolean object true OR false
            document.write(a.toUpperCase()+"<br/>");//String to uppercase
            document.write(a.toLowerCase()+ "<br/>");//The string is converted to lowercase
            document.write(a.split(' ')+"<br/>");//The string is separated into an array
        </script>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325913563&siteId=291194637