JS Summary of data types

Source: Internet
Author: User

JS data types are divided into primitive types (num, String, Boolean), Object types (objects, collections of attributes, special objects are arrays, global objects ), primitive values (null,undefined), except for primitive values, others have methods

JS is flexible for data type conversion

Attention:

1, Number type: overflow in arithmetic operation, underflow, or divide by zero will not error,

If the overflow result is infinite, it returns infinity, and negative infinity returns-infinity

If the result of the next overflow operation is infinitely close to 0, and is smaller than the minimum value that JS can represent, the return value is zero.

If divide by zero: Returns Infinity or-infinity, but 0/0, infinity divided by infinity, negative as root, and results return Nan

Objects (global objects, wrapper objects)

Global objects:

Wrapper object: Package properties and methods, such as var s = "abc"; Return S.LENGTH;//3

At the same time, = = is the same as the non-strict meaning, = = = Equal in strict sense

Mutable objects: such as var x = {O:1}; X.O = 2;return X;//2

A summary of some of the methods:

Time Method:

var t = new Date (2016,3,3);//April 3, 2016

var t = new Date (2016,3,3,17,10,30);//April 3, 2016 17:10:30

var t = new Date ();//Current time

T.getfullyear ();//2016

t.getmonth;//3--calculates the month starting from 0, so it's actually April.

T.getdate ();//3rd--counting days starting from 1

T.getday (); 0 Sunday--6 for Saturday

Method of String:

S.chatat (0); first character

S.chat (s.length-1); last character

S.substring (1,4); 第2-4个 character

S.slice (1,4); 第2-4个 character

S.indexof (' l '); The position of the first occurrence of the character L

S.lastindexof ("L"); the position of the last occurrence of the character I

S.indexof ("L", 3); position of L at first appearance after position 3

S.split (","); split into sub-strings

S.replace ("H", "H"); character substitution

S.topuppercase (); string capitalization

Regexp ();

JS Summary of data types

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.