Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: can anyone here tell me about this strange javascript character? i'm confusing

  1. #1
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Arrow can anyone here tell me about this strange javascript character? i'm confusing

    i'm new on javascript so i 'm little confusing about this little strange javascript characters:

    plese , can anyone here tell / explain this to me?

    var $name --> i dont know why javascript use "$" character? it look like php variable.. humk?

    &$name --> oh my good, i'm really confusing about this

    parent :: parse($name) -- > plese tellme.....

    $$this ---> what does it mean????


    and alse what is "prototype" ?
    and what is "jquery"?

    sorry, i'm a new player in javascript.
    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Prototype and Jquery are both javascript frameworks. A simpler way to use javascript. The $ variables are for frameworks - jquery uses it as a selector.
    Code:
    $("#div");
    Which would mean: document.getElementById('div').
    Jeremy | jfein.net

  3. #3
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Nile View Post
    Prototype and Jquery are both javascript frameworks. A simpler way to use javascript. The $ variables are for frameworks - jquery uses it as a selector.
    Code:
    $("#div");
    Which would mean: document.getElementById('div').

    hum, prototype and jquery is frameworks, okay i will read your link above.
    $("#div"); is used by jquery as selector , same as document.getElementById('div')


    so what about :

    var $name
    &$name
    parent :: parse($name)
    $$this


    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Can you point me to where you've seen that before? You may be getting mixed up with PHP Classes (or OOP).
    PHP Code:
    <?php
    class Test {
      var 
    $error;
      function 
    carry_error($err){
        
    $this->error .= $err."<br />";
      }
      function 
    throw_errors(){
        return 
    MakeErrors::error($this->error);
      }
    }
    class 
    MakeErrors {
      function 
    error($err){
        return 
    $err;
      }
    }
    $test = new Test();
    $test->carry_error('Some random error...');
    $test->carry_error('One more random error.. :-)');
    die(
    $test->throw_errors());
    ?>
    Jeremy | jfein.net

  5. #5
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    hi, sorry, i think i'm really confusing , hi may be you're right, this is php class

    sorry....
    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Can you post the code you saw with this code? Our job is to unconfuse confused people.
    Jeremy | jfein.net

  7. #7
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    var $name --> i dont know why javascript use "$" character? it look like php variable.. humk?
    A JavaScript variable name can start with $ symbol. In PHP without $ symbol it is not possible to make variable (I know constants does not have them) but in JavaScript the $ symbol is not compulsory. Rather we can say it like this in PHP $ symbol is not a part of the 'variable name' but in JavaScript if you use $ symbol it will be a part of the 'variable name'

  8. #8
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    var $name :

    Code:
    /**
     * search the forum
     */
    Forum.prototype.search = function (text, type, forum, u, disp)
    {	
    	this.loading ('SEARCHING');
    
    	var m = document.getElementById('main');
    	if (!m) 
    	{
    		new BxError("main div is not defined", "please name main content container");
    	}
    
    	var $this = this;
    
    	var h = function (r)
    	{		
    		var m = document.getElementById('main');		
    
    		m.innerHTML = r;
    
    		$this.runScripts ('main');
    
            $this.setWindowTitle(null); 
    
    		$this.stopLoading ();
    
    		$this.checkHeight ();
    	}
    
    	new BxXslTransform(this._base + "?action=search&text=" + text + "&type=" + type + "&forum=" + forum + "&u=" + u + "&disp=" + disp, urlXsl + "search.xsl", h);
    
    	document.h.makeHist('action=goto&search_result=1&' + text + '&' + type + '&' + forum + '&' + u + '&' + disp);
    
    	return false;
    }

    huh, i forget about the sample code of
    &$name
    parent :: parse($name)
    $$this

    i'm still confusing so i can not think . he he
    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

  9. #9
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Yes, as you see where you've bolded. They are using this to get to a parent element you cannot access from a function.

    Want english?

    It's just like saying I'm gonna destroy Jupiter.. But wait, I'm on Earth! You cannot do that, so what you have to do is put a few bombs on Jupiter - then leave to earth.

    [offtopic w/ a little bit of my two cents]
    Like my example. Very destructive, but Jupiter is my least favorite big giant gas planet. (or really least favorite planet)
    Of course, looking at the fact that Jupiter is made out of gas, and if I planted bombs on it, it'd probably explode before I have time to escape... What ever! GR, it's just an example.
    [/3 cents. ]
    Jeremy | jfein.net

  10. #10
    Join Date
    Aug 2008
    Location
    karanganyar, solo, indonesia
    Posts
    161
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by codeexploiter View Post
    A JavaScript variable name can start with $ symbol. In PHP without $ symbol it is not possible to make variable (I know constants does not have them) but in JavaScript the $ symbol is not compulsory. Rather we can say it like this in PHP $ symbol is not a part of the 'variable name' but in JavaScript if you use $ symbol it will be a part of the 'variable name'

    so? why do they ( designer) use this "$" on the variable name?
    hum, may be they (designer) want to make somebody like me to be confusing when reading their code
    ///////////////////////////////////////////////////
    ///// http://www.mediatutorial.web.id
    ///////////////////////////////////////////////////

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
  •