Come on, change the settimeout code to the result we want.

const obj = {
    name: " jsCoder",
    skill: ["es6", "react", "angular"],
    say: function () {
        for (var i = 0, len = this.skill.length; i < len; iPP) {
            setTimeout(function(){
                console.log(i);
                console.log(this.skill[i]);
            }(i), 0)
            console.log(i);
        }
    }
};
obj.say();

change it to settimeout to print I in normal order and print skill, in turn. We all know what methods there are. Please play

.
Feb.27,2021

          say: function ()
            {
                var that = this;
                for (var i = 0, len = this.skill.length; i < len; iPP)
                {
                    setTimeout(function()
                        {
                            console.log(i);
                            console.log(that.skill[i]);
                        }(i), 0)
                    console.log(i);
                }
            }

const obj = {

    name: " jsCoder",
    skill: ["es6", "react", "angular"],
    say: function () {
        this.skill.forEach(function(item,index){
            setTimeout(function(){
                console.log(index)
                console.log(item);
            },0)
        })
    },
    say2:function(){
        for (var i = 0, len = this.skill.length; i < len; iPP) {
            setTimeout(function(i,item){
                console.log(i);
                console.log(item);
            },0,i,this.skill[i]);
        }
    },
    say3:function(){
        const arr=this.skill.slice();
        let i=0;
        function pop(){
            const item=arr.shift();
            if(item){
                console.log(i);
                console.log(item);
                iPP;
                setTimeout(pop,0);
            }
        }
        setTimeout(pop,0);
    }
};
obj.say();
setTimeout(function(){
    obj.say2();
},1000)
setTimeout(function(){
    obj.say3();
},2000)

say: function () {
    for (var i = 0, len = this.skill.length; i < len; iPP) {
        setTimeout(((i) => {
                        return () => {
                            console.log(i);
                            console.log(this.skill[i]);
                        }
                    })(i), 0)
        console.log(i);
    }
}

function passTheRiver () {

const obj = {
    "count":0,
    name: " jsCoder",
    skill: ["es6", "react", "angular"],
    say: function () {
        var that = this;
        for (var i = 0, len = this.skill.length; i < len; iPP) {
            setTimeout(function(){
                console.log(that.count);
                console.log(that.skill[that.count]);
                that.countPP;
            }, 0)
            console.log(i);
        }
    }
};
obj.say();
Menu