Skip to content

Commit 3d4d38d

Browse files
committed
Optimization of loops
1 parent b232f1b commit 3d4d38d

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/share-buttons.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@
2929
var i,
3030
share = document.querySelectorAll('.share-btn');
3131

32-
for (i in share) {
33-
if (share.hasOwnProperty(i)) {
34-
this.initForElement(share[i]);
35-
}
32+
for (i = share.length; i--;) {
33+
this.initForElement(share[i]);
3634
}
3735
};
3836

@@ -43,15 +41,13 @@
4341
var i,
4442
a = el.querySelectorAll('a');
4543

46-
for (i in a) {
47-
if (a.hasOwnProperty(i)) {
48-
this.prepareLink(a[i], {
49-
id: '',
50-
url: this.getUrl(el),
51-
title: this.getTitle(el),
52-
desc: this.getDesc(el)
53-
});
54-
}
44+
for (i = a.length; i--;) {
45+
this.prepareLink(a[i], {
46+
id: '',
47+
url: this.getUrl(el),
48+
title: this.getTitle(el),
49+
desc: this.getDesc(el)
50+
});
5551
}
5652
};
5753

0 commit comments

Comments
 (0)