JavaScript Array, Date, String

Source: Internet
Author: User
Tags javascript array

Array: Arrays

Push: Adds a value to the end of the array, which can be one or more.

Alert (Arr.push (4, 5))

Join: Connect an array element with a delimiter in the middle.

var str = arr.join ("");
alert (str);

Reverse: The order of the points to the array is the operation itself.

Alert (Arr.reverse ());

splice: Adding or removing elements

var arr = new Array (6);
Arr[0] = "George";
ARR[1] = "John";
ARR[2] = "Thomas";
ARR[3] = "James";
ARR[4] = "Adrew";
ARR[5] = "Martin";
Arr.splice (0,1, "test");
Alert (arr);

concat: used to concatenate two or more strings.

Alert (Arr.concat (arr1, arr2));

String:

Length: A string that represents the lengths of the strings;

var str = "123456 ...";
alert (str.length);

split: used to separate strings, get an array of strings;

var str= "How is you doing today?";
document.write (Str.split ("") + "<br/>");
document.write (Str.split ("") + "<br/>");
document.write (Str.split ("", 1));

substr (): Used to extract strings

var str= "Hello world!";
document.write (STR.SUBSTR (6));

toLowerCase () is used to toggle the size of the string.

var str= "Hello world!";
document.write (Str.touppercase ());
document.write (Str.tolowercase ());

indexOf () detects whether a string exists within the detected string, and if so, returns the position where the string first appears, if no "1" is returned.

var str= "Hello World world!";
document.write (Str.indexof ("Hello") + "<br/>");
document.write (Str.indexof ("World") + "<br/>");
document.write (Str.indexof ("World"));

Interception of substring () strings

var str= "helloworld!";
document.write (Str.substring (3, 6));

Variable naming: Hump naming method Document.getelenment

Conversion of data types: var name (variable name) = parseint (text.value);//Convert value to integral type

Parsefloat ()//convert value to floating-point

Date: Day

Types of dates: date

var d =new Date (); Used to indicate that the current date and time are all time zone base standard times.    

var today = new Date ();
var year = Today.getfullyear ();
var month = Today.getmonth ();
var day = Today.getdate ();
var hours = today.gethours ();
var mins = Today.getminutes ();
var s = today.getseconds ();
var str = year + "Years" + (month + 1) + "Month" + Day + "days" + hours;
alert (str);

JavaScript Array, Date, String

Related Article

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.