JavaScript Language Basics

Source: Internet
Author: User

Data type of javascript:

JavaScript data types are divided into two categories: original Type and Object type
    
original type:
number, String, Boolean, null, undefined
where null and undefined represent unique members
    
of their particular type Object type: An
object type is a collection of attributes, each of which is an unordered key-value pair when it is composed of a key-value pair, and an ordered key-value pair is
our array. There is
    
also a special object where the function
function is an object that has the executable code associated with it. Running executable code by calling a function and returning the result
    
if you use the new operator to create a new object, we call it a constructor
. Each constructor defines a class--a collection of object combinations that are initialized by constructors (which can be considered as subclasses of object types

)
Arrays are Class (array)
functional class (function)
dates are class (date)
regular class (REGEXP) classes
and functions run through JS always

Digital

JavaScript is not distinguishing between integers and floating-point numbers, and all numbers are represented by floating-point numbers

Math

Now we're going to get to know an object that has a lot to do with numbers, math, and this guy can do lots of things!

Math.Round (0.6) rounded

Math.random () generates a pseudo random number that is greater than 0 or less than 1

Operation Overflow

When the JS operation overflow will not error, will use Infinity infinity and infinitesimal-infinity said;

If there is no meaningful operation will return Nan,nan's judgment is false in any case (he is not equal to himself), so judge him to use the isNaN () function

Parseint and Parsefloat

parseint (string, radix)

Radix, which represents the base of the conversion, which we often say 2, 8, 10, 16 and so on. range from 2~36, but we generally call this method in JS, the basic is based on 10 of the conversion.

If the argument is less than 2 or greater than 36, parseint () returns NaN.

parseint This function is very useful, you can return a string as an integer

<script type= "Text/javascript" >
    var a = parseint (' 334DD ');
    var B = parseint (' 3D34DD ');
    var c = parseint (' SS3D34DD ');
    s = ';
</script>

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.