Is my JS/Jquery methodology good?
        Posted  
        
            by 
                absentx
            
        on Programmers
        
        See other posts from Programmers
        
            or by absentx
        
        
        
        Published on 2013-10-27T06:20:47Z
        Indexed on 
            2013/10/27
            10:13 UTC
        
        
        Read the original article
        Hit count: 392
        
I always struggle with which of the stack sites is best to post "questions of theory" like this, but I think programmers is the best, if not, as usual a mod will move it etc...
I am seeking critique on what has become my normal methodology of writing javascript. I have become heavily reliant on the Jquery library, but I think this has helped me learn the native language better also. Anyways, please critique the following style of JS coding...buried are a lot of questions of scope, if you could point out the strengths and weaknesses of this style I would appreciate it.
var critique ={
     start: function(){
             globalness = 'GLOBAL-GLOBAL'; //available to all critique's methods
             var  notglobalness = 'LOCAL-LOCAL';// only available to critiques start method
             //am I using the "method" teminology properly here??
         $('#stuff').on('click','a.closer-target',function(){
             $target = $(this);
             if($target.hasClass('active')){
                 $target.removeClass('active');
             }
             else{
                 $target.addClass('active');
                 critique.madness($target);
             }
         })
               console.log(notglobalness+': at least I am useful at home');
         console.log('note here that: '+notglobalness+' is no longer available after this point, lets continue on:');
         critique.madness(notglobalness);
      },
      madness: function($e){
          // do a bunch of awesomeness with $e
          //but continue to keep it seperate because you think its best to keep things isolated.
          //send to the next function when complete here
          console.log('here is globalness, which is still available from the start method of critique!! ' + globalness);
          console.log('lets see if the globalness carries on to a new var object!!'); 
          console.log('the locally isolated variable of NOTGLOBALNESS is available here because it was passed to this method, lets show it:'+$e);
          carryOn.start();
      }
} //end critique
var carryOn={
    start: function(){
        console.log('any chance critique.globalness will work here??? lets see: ' +globalness);
        console.log('it absolutely does');
    }
}
$(document).ready(critique.start);
© Programmers or respective owner