Simple to understand what an object is

Source: Internet
Author: User

First, let's look at what the objects are.

Null,array,function,object,prototype,regexp,date, these are objects, where null is special, and where it's special, we'll talk about it next.

So how do you create an object? So~yi~z

//How to create an arrayMethod 1:vararr =[]; Method 2:vararr =NewArray ();//How to create a functionMethod 1:varfn =function() {} Method 2:varfn =Newfunction (); functions are created in a variety of ways, not listed here//How to create an objectMethod 1:varOBJ ={}; Method 2:varOBJ =NewObject ();//the creation of regular objectsMethod 1:varReg =//;Method 2:varReg =NewRegExp ();

Creation of Time objects
Method 1:var date = new Date ();

So what's the difference between an object and a normal type?

An object can customize properties and methods.

 var  str = "111" ;str.index  = 520;console.log (Str.index);  // undefined  //  var  arr = [];arr.index  = 520;console.log (Arr.index);  // 520  Arr.fn = function   "Chasing the Dream sub-blog"  //  chasing Dream blog    

The variable under the object is called the object's property, the function below the object, the method called the object, and the other object has many built-in methods, and properties, which we'll cover in a later section.

What are built-in objects and what are built-in methods?

In short, the built-in object and built-in method is to say that this object or method is JS in advance to provide you with, you can directly use, for custom means JS allows us to create some objects and methods. These are the built-in objects, like the following.

  

var New Array (); var New Function (); var New Object (), etc. ...

Here's a brief introduction.

  

Simple to understand what an object is

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.