Home > Web Front-end > JS Tutorial > body text

Instructions for using date objects, array objects, and two-dimensional arrays in JavaScript_Basic knowledge

WBOY
Release: 2016-05-16 16:25:16
Original
1230 people have browsed it

1. Date object

Format: Date object name=new Date([date parameter])
Date parameters: 1. Omitted (most commonly used)
                                                                                                                                                                                                                                                                                               

For example: today=new Date(“October 1,2008 12:00:00”);

3. Numerical format: year, month, day, [hour, minute, second]

For example: today=new Date(2008,10,1);

Copy code The code is as follows:






2. Array object

Create array object:

Format 1: Array object name=new Array([number of elements])

Format 2: Array object name=new Array([[Element 1][,Element 2,…]])

Format 3: Array object name=[Element 1[,Element 2,…]]

The array length is variable, and the array element types can be different

For example: fruit=new Array(3);//fruit=new Array();

fruit[0]=”apple”;

fruit[1]="Yali";

fruit[2]=”orange”;

             fruit=new Array("Apple", "Yali", "Orange");

fruit=["apple","ya pear","orange"];//The most used

Copy code The code is as follows:






Three and two-dimensional arrays

Copy code The code is as follows:






source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!