Basic Introduction to javascript object-oriented basics _ js object-oriented

Source: Internet
Author: User
This article introduces common objects in js, including descriptions of JavaScript objects string objects date () array mathematical object function objects. For more information, see What is an object?

To put it simply, the objects in programming languages are simplified for things in reality. For example, we are an object, but it is difficult for programming languages to fully describe such a complex object. Therefore, we must simplify the process. First, we should simplify people into a combination of attributes and actions, and then only keep the attributes and actions that are meaningful to the program. For example, if we develop a program to count the heights of people in a school, we can omit the human behaviors in this program and only keep the behaviors, only the height attribute is retained. In this way, we get the simplest object.

JavaScript string object

Object Attributes
In fact, we are already using objects in html dom. For example, we know that DOM nodes have some information, such as nodeName and nodeType, which are actually the attributes of node objects. The following uses a string as an example to check the attributes of an object.

String attributes
Var s = "I have a 7 character"; after defining the string s, we have a string object. We can access its length attribute (length ), this attribute does not need to be defined. It is a built-in attribute. The access method is as follows:

S. length click the button below to see the length of the string.

Alert (s. length)
String object method (behavior)
Similarly, an object can have behavior. Taking a String object as an example, we can let the string return letters or texts at a certain position. This is an action. You can use the buttons below to experience the attributes and methods of the string. This article will explain in detail how to use each method.

The Code is as follows:


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.