How to skip to next in javascript in a for-in with a while inside?

Don’t iterate over arrays using for...in. That syntax is for iterating over the properties of an object, which isn’t what you’re after.

As for your actual question, you can use the continue:

var y = [1, 2, 3, 4];

for (var i = 0; i < y.length; i++) {
    if (y[i] == 2) {
        continue;
    }

    console.log(y[i]);
}

This will print:

1
3
4

Actually, it looks like you want to break out of the while loop. You can use break for that:

while (condition){
    condition = callFunctionTwo(y[x]);
    break;
}

Take a look at do...while loops as well.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)