Introduction and simple use of JavaScript objects

Source: Internet
Author: User

JavaScript is an Object Oriented Programming (OOP) language.
JS is an object-oriented programming language (Object-Oriented ).

An OOP language allows you to define your own objects and make your own variable types.
The OOP language allows you to customize object and variable types.

--------------------------------------------------------------------------------

Object Oriented Programming
Programming of placement objects

JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to define your own objects and make your own variable types.
JS is the (OOP) language, which allows you to define... (same as above)

However, creating your own objects will be explained later, in the Advanced JavaScript section. we will start by looking at the built-in JavaScript objects, and how they are used. the next pages will explain each built-in JavaScript object in detail.
However, we will introduce how to create custom objects in advanced JS later. We will begin to observe the built-in JS objects and how to use them. The next page will detail each built-in JS object

Note that an object is just a special kind of data. An object has properties and methods.
Note that the object is only a special type of data. Objects have attributes and methods.

--------------------------------------------------------------------------------

Properties
Attribute

Properties are the values associated with an object.
Attribute is the object's connected Value

In the following example we are using the length property of the String object to return the number of characters in a string:
In the following example, we use the Length attribute of a string object to return the number of characters:

<Script type = "text/javascript">

Var txt = "Hello World! "
Document. write (txt. length)

</Script>

The output of the code above will be:
The above code will output:

12

--------------------------------------------------------------------------------

Methods
Method

Methods are the actions that can be stored med on objects.
Object methods can be executed.

In the following example we are using the toUpperCase () method of the String object to display a text in uppercase letters:
The following example uses the toUpperCase () method of the string object to display uppercase characters:

<Script type = "text/javascript">

Var str = "Hello world! "
Document. write (str. toUpperCase ())

</Script>

The output of the code above will be:
The above code output:

Hello world!

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.