Junior — Senior
Transform class into constructor function
livecode
Task condition
In the task, there is a class Test that needs to be transformed into a constructor function, preserving its properties and methods.
class Test {
constructor() {
this.a = 777;
}
say() {
console.log(10);
}
}
const res = new Test();
console.log(res);
res.say();
Rewrite this code so that instead of declaring a class, a constructor function is used, and methods are declared via the prototype or inside the function, as is common in the old JavaScript style.