r/javascript • • Mar 18 '19

What's your favorite, most useful javascript one-liner?

385 Upvotes

422 comments sorted by

View all comments

5

u/kommentz Mar 19 '19

I like this a lot because it uses time itself for the animation.

let currentDate = new Date();
hero.y = 100 + (Math.cos(currentDate.getTime() * 0.002) * 25);
→ More replies (2)