Javascript array loops get extra elements with plugin turned on
-
A customer of mine on Page Builder Sandwich reported a conflict between Smart Slider 3 and my plugin.
I did some debugging and found something weird. If SS3 is turned on, JS for loops get an extra element – a function – but only when looping through them.
If I execute this JS script on the console:
var arr = ['a', 'b', 'c'];
for ( var i in arr ) {
console.log(arr[i]);
}Here’s what happens with all plugins turned off & using Twenty Sixteen:
a
b
cThis is the expected result. But if I turn on SS3, I get this:
a
b
c
function () {
var what, a = arguments, L = a.length, ax;
while (L && this.length) {
what = a[--L];
while ((ax = this.indexOf(what)) !== -1) {
…This is affecting all arrays that are looped through and causes errors in other JS in the page if other plugins are turned on also.
- The topic ‘Javascript array loops get extra elements with plugin turned on’ is closed to new replies.