正規演算子

5199 ワード

Math     Date String       ,        Math(),  Math.sin()     ,         

      ,   Math                   .

 π  Math.PI

         Math.sqrt(15)

         Math.abs(-5);

     console.log(Math.ceil(5.1));

     floor(x)

             Math.round(x)

Math.random()   0-1      

JavaScript Date   

//            ,      

var date1 = new Date("2016-9-1)

var date2 = new Date("2016-9-20)

//            ,      var res = date2-date1;

// Date   ,          var time = date1.getFullYear(); console.log(time);

// Date             .

var d = date1. getDate();

//   : 1,date1        ,      .

var date3 = new Date(); console.log(date3); //  :Fri Mar 09 2018 20:19:46 GMT+0800 (CST) console.log(date3.toUTCString()); //  :Fri, 09 Mar 2018 12:19:46 GMT

JavaScript String   

//anchor()   HTML 

var text = "hello World"; console.log(text.anchor("text")   : hello World

var str = "Hello world"; console.log(str.length);//  12

     

reg = /    (     )/    

g       i        

var reg = /test/g;      text    

\d    
var reg = /\d/g;       

\w      :           var reg = /\w/g;                .

//.            (
\t \b \ ) var reg = /./g; //\s \s . var reg = /\s/g; /s . var reg = /\w{}/g; 6-12 var reg = /\d{2,3}/g; 2 3 . // var reg = /(34)|(32)/g , . var reg = /(34)|(32)/g = var reg =/3[24]/g var reg = /^34/g; , 34 , var reg = /34$/g; str 34 34 va reg = /^\d{11}&/g; 1 , 3 6 var reg = /^\d{3,6}$/g; 3 6 . // 11 .1 3-8 var reg = /^1[10379]|4[7]5[0258]|6[1]|7[378]|8[029])\d{8}$/g;