Results 1 to 6 of 6

Thread: How to create a class in java script

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    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);

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    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 ()
        {
          /*
         *
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,389

    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.  

Similar Threads

  1. Converting java class to java bean class
    By Ucchal in forum Software Development
    Replies: 6
    Last Post: 09-08-2010, 10:24 AM
  2. How to create mouse event using Robot class in java?
    By Luis-Fernando in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 08:03 PM
  3. How to create key press event using Robot class in java?
    By Kasper in forum Software Development
    Replies: 4
    Last Post: 03-02-2010, 06:33 PM
  4. How to create an inner class in java?
    By MABON in forum Software Development
    Replies: 4
    Last Post: 01-02-2010, 04:40 PM
  5. Java Programming Language Basics: Reflection Basics and Class Class
    By mayuri_gunjan in forum Guides & Tutorials
    Replies: 6
    Last Post: 29-08-2005, 12:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,009,414.58305 seconds with 17 queries