Introduction to JavaScript OOP object-oriented

Source: Internet
Author: User

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. The object has attributes and methods.

Attribute
Attribute refers to the value related to the object.

Example:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var txt = "Hello World! "
Document. write (txt. length) // use the length attribute of the string object to calculate the number of characters in the string, and the output is: 12
</Script>

Method
A method is a behavior that can be executed by an object (or a function that can be completed ).
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var str = "Hello world! "
Document. write (str. toUpperCase () // use the toUpperCase () method of the string object to display uppercase letters and texts. Output: hello world!
</Script>

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.