19
crisz
7y

var i = 0;
setInterval(function(){
document.getElementById("el").style.width = i + "px";
i+=10;
},100);
And, children, this is how we were used to create animations years ago

Comments
  • 0
    But... where's the for loop?
  • 0
    @SpencerBeige It's a setInterval(). There's no requirement for a loop, it will be called every 100 milliseconds

    There should, however, probably be a way to clearInterval() when the width has reached its desired size
  • 0
    ouch..
  • 1
    To see how the var can be used hurts my eyes 😵. God bless let!
  • 0
    @LinusCDE I use Javascript almost daily, don't think I've ever used let :)
  • 0
    @NufMeister I have before, but not regularly. Mainly due to lack of IE support.

    I'm an old school JS though. I like my constant variables beginning with an _
  • 0
    @NufMeister I'm aware I could (and I may be stuck in my ways here), but I prefer clean looking code
    A lot of the ES6 compilers tend to put gunf in where it isn't needed, in my opinion

    I'm primary a Web developer, and currently I see no need for the use of let or consts
    Even in some of the Web Apps I've built
Add Comment