0

I'm trying to make a function in which I can reference an object using information passed into that function. Here's some example code:

        function pass(n) {
            alert(object.n);
        }
        pass("type");

In this example I want to be able to alert with the contents of object at type location. How can I do this such that it will work? It also doesn't work when I instead pass a variable like so:

            function pass(n) {
                alert(object.n);
            }
            var m = "type";
            pass(m);

This is all assuming that my object has something in object.n or object.type.

Any info would help, thanks!

Egrodo
  • 350
  • 1
  • 5
  • 15

0 Answers0