Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a standard in namespace capitalization for Javascript

I'm adopting a large mish-mash of Javascript / jQuery code. I'd like to move it to Backbone.js but as an intermediary, I'm trying to namespace it so that it is sligthtly more modular.

I am wondering if there is a standard for namespaces for Javascript. I was going to do something like this:

var arc={
  name:"Spock",

  nav:function(){
    //alert('name' + this.name);
    obj=get_nav_obj();
    get_to_api_v2(obj);
  }

};

Should arc be capitalized? I tend to see capitalized but since rest of site is in Ruby, lowercase might be more consistent.

thx

like image 605
timpone Avatar asked Apr 05 '12 15:04

timpone


1 Answers

In javascript, camelCase is used for regular identifiers. CAPSLOCKS is used for "constants". ProperCase is used for object constructors (indicating they should always be invoked using new).

like image 104
jbabey Avatar answered Nov 09 '22 07:11

jbabey