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; }

22nd May 2021, 8:25 PM
Тимур Завьялов
Тимур Завьялов - avatar
6 ответов
+ 2
Here is an example to make it clear for anyone who don't understand . https://code.sololearn.com/Wg5gKn7YXgAQ/?ref=app
22nd May 2021, 9:15 PM
Abhay
Abhay - avatar
+ 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
22nd May 2021, 8:59 PM
Abhay
Abhay - avatar
+ 1
Abhay, thanks
22nd May 2021, 9:06 PM
Тимур Завьялов
Тимур Завьялов - avatar
0
is it java or javascript ?
22nd May 2021, 8:28 PM
Abhay
Abhay - avatar
0
javascript
22nd May 2021, 8:30 PM
Тимур Завьялов
Тимур Завьялов - avatar
0
I understood correctly that width is going to be pieced together. First comes w then + i then + d and so on?
22nd May 2021, 8:34 PM
Тимур Завьялов
Тимур Завьялов - avatar