Is there a more succinct way of writing this simple JavaScript loop?
I think at the very least I'd rearrange the cases to make the dichotomy between Array.isArray and !Array.isArray more direct and apparent:

while (i &lt; x) {
    if (typeof arr[i] === 'string') {
        text = arr[i];
    }
    else if (typeof arr[i] === 'object') {
        if (Array.isArray(arr[i])) {
            child = arr[i];
        }
        else {
            attr = arr[i];
        }
    }
    i++;
}


That's not really a lot shorter but I think it makes the intent rather more clear (at least assuming I've divined the real intent correctly).