SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: what is init?

  1. #1
    SitePoint Addict sedna's Avatar
    Join Date
    Jan 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what is init?

    when I read some sitepoint books they have init, is that a special function thats built into javascript or is it a function the author just made up?

    example

    Code:
    this.init = function() {
    if (!this.reg) { .....

  2. #2
    SitePoint Addict
    Join Date
    Jun 2006
    Location
    Durban, South Africa
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the current example, init is a function that is being defined.

    The

    if (!this.reg) { .....
    is the contents of the function. So if you called init(); you would be running the above code.

    Also the use of 'this' indicates that the function being created is part of a class.

    Hope this helps
    Cheers

  3. #3
    SitePoint Addict sedna's Avatar
    Join Date
    Jan 2006
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks poizn thats help me out mite take time to sink in lol since I have only just started to learn

  4. #4
    SitePoint Addict
    Join Date
    Jun 2006
    Location
    Durban, South Africa
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool glad I could help


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
  •