Dynamic function call

by jasper502

JavaScript

function type(type) {

      if (type == null) {
        return {}
      } else {
        return optionTypes[type]
      }


    };

    var optionTypes = {

      test: {
        options: [{
          value: "opt1",
          text: "Option 1"
        }, {
          value: "opt2",
          text: "Option 2"
        }, ]
      },
      max3: {
        maxItems: 3
      },
      max5: {
        maxItems: 5
      }

    }