[JavaScript] Introduction to JavaScript objects

Source: Internet
Author: User

Javascript is object-orientedProgramming Language(OOP ).

The OOP language enables us to customize object and variable types.

Object-Oriented Programming

Javascript is an object-oriented programming language (OOP ). The OOP language enables us to define our own objects and variable types.

Don't worry. We will explain how to create your own objects in the advanced JavaScript section. Now, we need to learn about built-in JavaScript objects and how to use them. Starting from the next section, we will explain these built-in JavaScript objects in sequence.

Note:: The object is only a special type of data. The object has attributes and methods.

Attribute

Attribute refers to the value related to the object.

In the following example, we use the Length attribute of the string object to calculate the number of characters in the string.

<SCRIPT type = "text/JavaScript"> var TXT = "Hello world! "Document. Write (txt.Length) </SCRIPT>

The aboveCodeOutput:

12
Method

A method is a behavior that can be executed by an object (or a function that can be completed ).

In the following example, we use the touppercase () method of the string object to display uppercase letters and texts.

<SCRIPT type = "text/JavaScript"> var STR = "Hello world! "Document. Write (Str.Touppercase ()) </SCRIPT>

The above code output is:

Hello world!

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.