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>