Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-02-2010
Member
 
Join Date: Feb 2010
Posts: 537
How to create a class in java script

Hi all,

I am a new programmer in java, I do not understand the class in java script, in fact, our class is a simulation of the real world, calling it "category" or "type" may be easier to understand some. I only know that "animal" is a class, and specifically an individual is the "person" in this class an instance of "person" can have many examples, but the "person" in this category only. Please clear my doubt. Thanks in advance.
Reply With Quote
  #2  
Old 11-02-2010
Member
 
Join Date: May 2008
Posts: 2,008
How to create a class in java script

I am using C + +, In the C++ Is a class is declare a class, JavaScript and C + + is different it uses the same function with the function to the statement, which made many friends in school Jscript classes and functions to mix, and the function and type in the Jscript have indeed been mixed, but the use of a long time will naturally have to understand,
function User ()
  {
this.Name; / / name
  }
The code above defines a User (user) class, which has attributes: Name (name). Name is an attribute of User class.
Reply With Quote
  #3  
Old 11-02-2010
Member
 
Join Date: Apr 2008
Posts: 2,001
How to create a class in java script

A class has a fixed attribute, but an instance of the class has a different attribute values, like I belong to the "people" of this class, gender is male, but I have a female classmate, and she also belongs to "people" category, but attribute value is her sex to female. you declare an instance of a class do
  
var my = new User ();
var bro = new User ();

Check that and reply.
Reply With Quote
  #4  
Old 11-02-2010
Member
 
Join Date: May 2008
Posts: 2,293
How to create a class in java script

You can use Class attributes by this process The use (I) is an instance of the class User, it has User to it all: Name attribute, Sex and Age property attribute, we can set it this way, the properties of:
  
Wo.Name = "red x ";
window.document.write (user.Name);
user1.Name = "the original";
window.document.write (user.Name);
Reply With Quote
  #5  
Old 11-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
How to create a class in java script

I tell you how to use Method in a class, I think that the act would become easier to understand. A person has many common behavior, such as sleeping, eating, walking, etc., and now we add a class to myUser Posted approach.
  
function myUser ()
  {
this.Name;
this.ArticleCount = 0;
    
this.NewArticle = function ()
    {
      /*
     *
}
Reply With Quote
  #6  
Old 11-02-2010
Member
 
Join Date: May 2008
Posts: 2,383
How to create a class in java script

You can also use Static property in class that is called public property, it does not belong to a class instance, but rather belong to a class directly.
Static property statement is:
The class name. Prototype. Attribute name = attribute value;
For example to define a class YouUser the number of registered users Count:
 YouUser.prototype.Count = 0;
The reading method is like   
YouUser.prototype.Count directly and Use user.Count.  
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to create a class in java script"
Thread Thread Starter Forum Replies Last Post
Converting java class to java bean class Ucchal Software Development 6 09-08-2010 10:24 AM
How to create mouse event using Robot class in java? Luis-Fernando Software Development 4 03-02-2010 08:03 PM
How to create key press event using Robot class in java? Kasper Software Development 4 03-02-2010 06:33 PM
How to create an inner class in java? MABON Software Development 4 01-02-2010 04:40 PM
Java Programming Language Basics: Reflection Basics and Class Class mayuri_gunjan Guides & Tutorials 6 29-08-2005 12:04 AM


All times are GMT +5.5. The time now is 09:09 PM.