Dónal
Dónal

Reputation: 187529

add function to namespace

I've defined the following JS constructor function

function FV.Map(element) {
  // impl omitted
}

The function definition causes the following error to appear in Firebug

missing ( before formal parameters

The FV is a global object that I use as a namespace for all my functions. Apparently this is not the right way to add this function to this namespace, what should I use instead?

Upvotes: 1

Views: 3270

Answers (2)

elev8ed
elev8ed

Reputation: 193

A more intuitive syntax would perhaps be this...

window.FV = {
    Map: function(element){
       Do Something
    },
    Morefuncs: function(element, element2){
       Do something else
    }
};

Upvotes: 0

millimoose
millimoose

Reputation: 39950

window.FV = window.FV || {}
FV.Map = function(element) {
    //…
}

Upvotes: 3

Related Questions