Home > front end >  How to create a node object variables, initialize the same value
How to create a node object variables, initialize the same value

Time:12-12

How to simplify the creation of iconArray this object

 
Var iconArray=
{
Icona: document. The createElement method (' div '),
Iconb: document. The createElement method (' div '),
Iconc: document. The createElement method (' div ')
}

CodePudding user response:

You put an object in this meaningless, so see you like this, does not want to reuse the same business logic, you according to your actual demand after extraction as a function to call

CodePudding user response:

reference 1/f, bubble fish _ response:
you put an object in this meaningless, so see you like this, does not want to reuse the same business logic, you according to your actual demand to extract have to do is to write a function to call after


Thank you bosses advice, but I want to assignment respectively 0 elements

If remove icona, iconb, iconc, objects, how to define

CodePudding user response:

Not very know what you mean, in front of me said you this is meaningless, because the document. The createElement method (' div ') is the primary method, you might write a function
 function createElement method (tagName) {
Return the document. The createElement method (tagName);
}


Don't know what you said to remove those, and define what is the meaning of object, the object you provide iconArray so three properties, is to create a div, then you can create not just a matter of directly, you can either write clear, complete demand that you lost the object, I don't understand your intentions...
  • Related