JSFiddle - React, Tailwind, and code Playground

by Dan Mathisen

JavaScript

// I have a simple app...
var myApp = {
	settings: {
  	defaultName: "Default App"
  }
}

// Now let's pretend I got 'moduleName' from a parameter in the URL - it comes in as a string...
var appName = "myApp";

// How can I access myApp.settings now?
// I can't do this because `appName` is a string
var settings1 = appName.settings;
var settings2 = [appName].settings; // also doesn't work

// I tried stripping the quotes without any luck