Just to be clear, a class that inherits DynamicObject (in C# of course) is not the same concept as JavaScript's variables being dynamic. DynamicObject allows the implementer to programmatically determine what members an object has, including methods.
Edit: I understand that JavaScript objects can have any members added to them at run time. That's not at all what I'm talking about. Here's a C# example showing what DynamicObject does:
public class SampleObject : DynamicObject
{
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
result = binder.Name;
return true;
}
}
dynamic obj = new SampleObject();
Console.WriteLine(obj.SampleProperty);
//Prints "SampleProperty".
When a member of obj is accessed, it uses the TryGetMember to programmatically determine whether the member exists and what its value is. In short, the existence of a member is determined when it's requested, not by adding it before hand. I hope this clarifies the question a little. In case you're wondering, I'm trying to determine if it's possible to make an object in JavaScript, that when the function call syntax is used on it like so:
myAPI.uploadSomeData(data1, data2)
The uploadSomeData call goes to a "TryGetMember" like function, which performs an $.ajax call using the name "uploadSomeData" to generate the URL, and the return value is the result.