The _javascript technique of "static class" about JavaScript

Source: Internet
Author: User
Tags static class
(The following questions are only for JavaScript, please note that if you have a problem with the statement, please laugh over the line)
1, what is static class/Pseudo static class
2. What is the syntax for writing static classes in Javsscript? (including arrays, constants, whatever, want to be complete)
3. Give a simple example of your explanation
The key is the second one, the rest is not to say
A static class is a top-level class, like the Math class, which is actually a global variable. It's just that the variable is not defined by you, but JS. You just use it. It's better to use the Math class than to create a photo if you want to find a circle the area of the S=MATH.PI*R*R variable R is to be stated first.
There are static methods, and so on, and so on. A string can be fromCharCode (Value1,value2,value3 ...) with a static method of the String class. That's all you need.
Str=string.fromcharcode (Value1,value2,value3 ...)
<script> var hutia_hate_staticclass={name: "Hutia",//A Property Sex: "Unknown",//Another property, be Awar E That's should use, to devide two variable talk:function (words) {//The method for the object alert (words); } hutia_hate_staticclass.talk ("I AM" +hutia_hate_staticclass.name); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

First of all, thanks to the lovely WT1985 and dear hutia:d, thank you for your help.

I understand the nature of this thing, from the example of Hutia is also to understand most of the things, I first said my understanding ha:
1, this thing to put it bluntly is (global variable/No need to instantiate the constructor function)
2, this thing can play similar to other languages in the "Class" function
3, this thing grammar is roughly the same as usual, but must be changed into
(Property name/Method name): (Property value/Method description)
4, each attribute with "," separated

So
function FuncName (IPT1) written as funcname function (IPT1)
var str= "value" written as str: "Value"
var myarray=new Array () written myarray:[] (this is to see my example of Foshan people guess)

What about the grammatical rules of other objects? The first two can be guessed, but the declaration of the array of the "[]" symbol if I do not see the example of Foshan people, I do not know, there is a specific rule? Which Big Brother big sister again to explain: confused:
You're right, that's fine.

As for your last question, it's just JS syntax.

A=new Array (); A[0]=1; a[1]=2;
is equivalent to
a=[1,2];

Similarly, there are
A=new Object (); A.name= "Hutia";
is equivalent to
a={Name: "Hutia"}


In general, JS still has a lot of uncommon syntax, for example
Wacky Syntax <script> (function (name) {window["eval"] ("alert (' I AM" +name+ ")") ("Hutia") </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
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.