0
Hey guys, please, can someone explain to me what this code stands for? Let's say I got the width attribute
getAttributes() { let str = ''; for (let i = 0; i < this.attributes.length; i++) { str += `${this.attributes[i].name}="${this.attributes[i].value}" `; if (i != this.attributes.length - 1) { str += ' '; } } return str; }
6 Respostas
+ 2
Here is an example to make it clear for anyone who don't understand .
https://code.sololearn.com/Wg5gKn7YXgAQ/?ref=app
+ 1
Тимур Завьялов "this" here refers to some object , dom or window or any other object . If it's a dom object then it needs to have attribute "w", "i" and "d" for it to output that .
Suppose a div object has an attribute width with value 200px , then your code should output the following :
width=200px
+ 1
Abhay, thanks
0
is it java or javascript ?
0
javascript
0
I understood correctly that width is going to be pieced together. First comes w then + i then + d and so on?