Answers for "javascript dynamic classes"


javascript dynamic classes

JavaScript "classes", just like any other object, can be dynamically created. So, yes, this can be done.

You would do something like this in the code handling the AJAX response (assuming that the AJAX response was providing the name of the new "class", and it's in a variable called newClassName):

window[newClassName] = function() {
  // New class name constructor code

window[newClassName].prototype = {

  someProperty: "someValue",

  someMethod: function(a, b) {

  someOtherMethod: function(x) {
Posted by: Guest on March-22-2021

Code answers related to "javascript dynamic classes"

Code answers related to "Javascript"

Browse Popular Code Answers by Language