How can I pass a part of an expression as an argument as a string? Something like this:
let t = "val";
$('.class').t();
UPD
UPD 2
My mistake, I was just redefining an already declared variable.
How can I pass a part of an expression as an argument as a string? Something like this:
let t = "val";
$('.class').t();
UPD
UPD 2
My mistake, I was just redefining an already declared variable.
You can use Bracket notation to access the property of an object dynamically:
let t = "val";
$('.class')[t]();
This will call the method with the name that matches the value of the t variable on the jQuery object with the class. If the method exists on the object, it will be called with the appropriate arguments.