-2
var param = "statut";

// I want this expression :

data.param.function1().function2();

// to be equivalent to :

data.statut.function1().function2();
Sudhir Ojha
  • 3,247
  • 3
  • 14
  • 24
  • 1
    maybe this will help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors. `data[param]function1().function2()` Square bracket notation allows you to dynamically access properties of an Object – Francis Leigh May 10 '19 at 12:08
  • Possible duplicate of [Dynamically access object property using variable](https://stackoverflow.com/questions/4244896/dynamically-access-object-property-using-variable) – VLAZ May 10 '19 at 12:08

1 Answers1

4

Try to use:

var param = 'status';
data[param]function1().function2()
Matteo Pagani
  • 545
  • 5
  • 14