Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the basic functions of JavaScript

Shulou Source: shulou.com Published: 2022-06-01 10:31:01 10月29日 Update

This article introduces the relevant knowledge of "what are the basic functions of JavaScript". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Time function Date

1 、 Date

In JavaScript, you use the Date () function to get the time.

Var date = new Date ()

2. Create a specified time object

You need to pass a string representing the time in the constructor as a parameter, the format of the date month / day / year: minutes: seconds

Var date2 = new Date ("11 Compact 2 Universe 20 21 18:15:00")

3. GetDate ()

Gets the number of days the current date object is.

4. GetDay ()

Gets the day of the week of the current date object and returns a value of 0-6. 0 means Sunday, 1 means Monday.

5. GetMonth ()

Gets the month of the current time object, 0 for January, 1 for February.

6. GetFullYear ()

Get year

7. GetTime ()

Gets the timestamp of the current date object.

Timestamp, which refers to the number of milliseconds spent from 00:00:00 GMT on January 1, 1970 to the current date (1 second = 1000 milliseconds), which is used by the underlying computer to save time.

8. Use timestamps to test the performance of code execution

Var start = Date.now ()

For (var iTunes 0; I

Tags: Character string position time parameter number content function object date between array index random number generation method coding operation basis different Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL MariaDB macOS NVidia