Library is a collection of functionality in form of code which can be reused.
Here are the steps for implementing the library.
Write the classes, methods and functions in IIFE (Immediately Invoked Function Expression).
Expose the required classes, methods and functions to outside world.
Use the library name to use the classes and functions of the library.
Create a library to provide reflection capability - getting properties, getting methods and dynamically invoking the method.
The library will use namespace and only required methods will be exposed to outside world.
Usage - _Reflection.Invoke(param1, ....)
We will write code of library in Immediately Invoked Function Expression (IIFE) so that classes and functions of library will be in that function scope.
We have global as parameter and passing this to function so global will have value of this. this is pointing to window object so global will be pointing window object.
Here is the function for dynamically invoking the method.
Now we want to provide namespace. So we will have literal object _Reflection. This object will have classes and functions to provide interface to outside world. It will expose only required one to outside world.
Now the library _Reflection is available which can be used in user file._Reflection.js
We have the class and we want to use the library function to invoke the method dynamically. Here is the class and use of library for invoking the method.reflection.js
We can use them in html file. First we have to write the library file, then we can write user file.reflectiondemo.htm