Skip to content Skip to sidebar Skip to footer

Putting A Variable Into Name Of Function Javascript

I want to do the following: var table = new google.visualization.XXXXX(document.getElementById(divId)); where the X's represent a variable that is set previously. Just so you know

Solution 1:

Use square bracket notation.

varXXXXX = "someString";
var table = new google.visualization[XXXXX](document.getElementById(divId));

Solution 2:

Pretty simple:

var table = new google.visualization[XXXXX](document.getElementById(divId));

Should do the trick.

Post a Comment for "Putting A Variable Into Name Of Function Javascript"