JS built-in objects

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Built-in objects</title>6 <Script>7     //5.Date8     //1) How to create a date9     varD1= NewDate ();Ten     varD2= NewDate ("2017/09/01 09:09:09"); One Console.log (d1); A Console.log (D2); -     //2) Convert to a local format string - Console.log (d1.tolocaledatestring ()); the Console.log (d1.tolocaletimestring ()); -     //3) Read Time component -     vary=d1.getfullyear (); -     //month starts from 0 +     varm=D1.getmonth ()+1; -     varD=d1.getdate (); +     varToday=y+ "years" +m+ "Month" +D+ "Day"; A Console.log (today); at      -     //6.RegExp -     varStr= "You can up,no can no BB."; -     //1) How to create a regular object -     varReg= /No/; -     //2) test () in     //detects if the string contains a substring that matches a regular match - Console.log (Reg.test (str)); to     //3) EXEC () +     //Normal Mode -     //detects a 1th substring that matches a regular match from a string the Console.log (reg.exec (str)); * Console.log (reg.exec (str)); $     //In the global modePanax Notoginseng     //1th Call, the 1th substring matched to a regular match is detected from the string -     //Nth call, the nth substring matched to the regular match is detected from the string the Reg= /No/G; + Console.log (reg.exec (str)); A Console.log (reg.exec (str)); the Console.log (reg.exec (str)); + Console.log (reg.exec (str)); -      $     //7.Function $     functionsum () { -         vars= 0; -         if(arguments.length) { the              for(varI=0; I<Arguments.length;i++) { - s+=Arguments[i];Wuyi             } the         } -         returns; Wu     } -      About     //Call function immediately when page loads $ console.log (SUM (1,2)); - console.log (SUM (3,4,5,6)); -      - </Script> A </Head> + <Body> the      - </Body> $ </HTML>

JS built-in objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.