Use value of a variable as name for another variable

I have a function that uses an array to set names for different things

var settings = {
    slug: "foo"
}

Now, i want to create a variable, whitch name is the value of settings.slug, in this case foo

This obviously does not work:

var settings.slug = new Schema({
  title : String
, content   : String
});

this[settings.slug] = ...

This should work.

The only way to do this is to use bracket notation and attach it to an existing object. For example, you could make it a global variable by attaching it to the global object:

global[settings.slug] = new Schema({
  title   : String
, content : String
});

global['foo'];  // your Schema object
foo;  // automatically will cascade to the global window variable global['foo']

Use the bracket notation:

someObj[settings.slug] = new Schema(...);

// equivalent to 
someObj["foo"] = ...
// or
someObj.foo = ...

However, you should not set properties of the global object imho. Use an extra namespace object if you need variable property names, but on the global object you are running the risk of overwriting some important globals.