JavaScript Math Object, String objects

<! DOCTYPE HTML> 
<HTML> 
    <head> 
        <Meta charset = " UTF-. 8 " > 
        <title> </ title> 
    </ head> 
    <body> 
        <Script type = " text / JavaScript " >
             // the Math Objects' with class called directly without creating objects
             // 1. property 
                . 1 . .PI     // [pi] 
                2 . .SQRT1_2     // return the reciprocal square root of two (approximately equal to 0.707). 
                . 3 . .SQRT2     // returns the square root of two (approximately 1.414).
//                 ...
             // 2. The method
 //            .Round 1. ()   // rounded to the nearest integer
 //             2. .random () // a randomly generated number between (0-1)
             // randomly generates an integer between [XY]
 //             Math.round ( math.random () * (YX) + X); 
            var a = Math.round (Math.random () * . 5 + 15 ); // randomly generates a number between a 10-15 
            console.log (a);
 //             3. .ceil () // rounded up 
            the console.log (Math.floor ( 1.6 )); // 2
 //             4. .floor () // rounded down 
            console.log (Math.ceil ( 1.6));//1
//            5.    .max(1,2,3,...) //
//                ...
//                https://www.w3cschool.cn/jsref/jsref-obj-math.html
    

       
       // 1.String objects
             // var STR = new new String ( "W is the Hello") 
            var STR = " the Hello W is " 
            // 2. Attribute 
                1 .str.length
                 2 .str [ 0 ]
             // 3. Method 
                1 . the charAt ( 0 ) // STR [0] 
                2 . .toUpperCase () // string to uppercase 
                . 3 . .toLowerCase () //
                 . 4 . .indexOf (a, b) // If the write b, from the start b back to find whether a string containing the contents of a location of the first occurrence of the specified
                                     // have to return to its smallest subscript
                                    // No, return -1 
                5 . .LastIndexOf () // Similar 4, after looking forward to return to a position for the first time, the biggest index 
                6 . .Split ( "" )   // If write to its going to be split array 
                    ...            
 //                 https://www.w3cschool.cn/jsref/jsref-lastindexof.html

 

        </script>
        
    </body>
</html>

 

Guess you like

Origin www.cnblogs.com/wangdongwei/p/11247046.html
Recommended