<script type= "Text/javascript" >
var txt= "Hello world!"
document.write (txt.length)//Use the Length property of the string object to calculate the number of characters in the string, output: 12
</script>
<script type= "Text/javascript" >
var str= "Hello world!"
document.write (Str.touppercase ())//uses the toUpperCase () method of the string object to display the uppercase text. Output as: Hello world!
</script>
Classes and objects
Objects (object) are an instance of class (instance). If the object is compared to a house, then class is the design drawing of the house. So the focus of object-oriented programming is the design of classes, not the design of objects. A class can encapsulate data and functions together, where a function represents the behavior (or service) of a class. class provides keywords public, protected, and private to declare which data and functions are publicly owned, protected, or private.
This can achieve the purpose of information hiding, that is, let classes only expose what must be known to the outside world, and hide everything else. We can not abuse the packaging function of the class, do not treat it as a hotpot, everything thrown in.
When designing a class, "behavior-centric", that is, first consider what kind of function the class should provide.
It is easy to design an orphaned class, and it is difficult to design the base class and its derived classes correctly. Because some do not know the concepts of "inheritance" (inheritance), "combination" (composition), "polymorphism" (polymorphism).