I work with JavaScript (ECMAScript 5). I have a class like this:
My class
function elementClass(htmlType, cssClass, text, value, id) {
this.htmlType = htmlType;
this.cssClass = cssClass;
this.text = text;
this.value = value;
this.id = id;
}
Sometimes I need set some properties and I want to use code like below:
var newElement = new elementClass(htmlType ="div",cssClass = "form-group",id = "div1");
I need to pass div1
as id
but it passed as third argument.
I can use below code for do it:
var newElement3 = new elementClass();
newElement3.htmlType = "div";
newElement3.cssClass = "form-group";
newElement3.id = "div1";
But I want to minimize the code numbers like:
var newElement = new elementClass(htmlType ="div",cssClass = "form-group",id = "div1");
I read many topics but I couldn't find any solution for doing it.
Is there any way to do it?
Thanks advance.