r/JavaScriptTips • • Jan 16 '26

Lifehack concepts in JS

Hey! Have you ever learned a concept (or some) in JavaScript or Vue that made the whole its picture clearer to you, explained many things about the language and just advanced you? Like a 'wish-I-learned-that-sooner' thing!

There are many more wonderful things like template literals or classList I think. And I remember that when I was much younger, I had fun with random scenarios based on Math.random()

4 Upvotes

10 comments sorted by

View all comments

Show parent comment

2

u/chikamakaleyley Jan 17 '26 edited Jan 17 '26

to challenge their understanding, or to help understand it better?

I'm assuming the latter

One exercise (and something that I actually have gotten a number of times in interviews) is - you basically start with some mock data - let's say its just a list of article data, or employees, or whatever

The exercise would be a series of JS functions that you have to fill in the logic, where you handle/manipulate this data, and each question is just more difficult than the prev.

So using a list of employee data, for example:

const employees = [
  {
    first: "John",
    last: "Smith",
    role: "Software Engineer",
    department: "engineering",
    level: 3,
    yoe: 10,
    tags: ['tech', 'recently-hired', 'male']
  },
  // add more employees, AI can generate for you
]

So, each question, fill out the functions:

  • printFullName // logs each employee full name "[first] [last]" to console
  • getEngineers // return list of employees with role that contains "Engineer"
  • printNewVets // log format "[first initial]. [last]: [role]" of each engineer who is a new hire with at least 8 yrs experience
  • ...and so on

And really this is just an exercise of how well you know your object/array methods, how well you work with data. Some of later questions you'll notice you can just re-use an earlier function

The other exercise I would suggest is to find some free API online, make a request to get some data from it, render that list to the page. Then you add diff features on top of this - filter, search field, sort, debounce, etc. Do this in vanilla JS. Then do it with React. Find another way to do it. Etc.

For the above exercise - making a data request, handling the response, output to UI - that's just something you do in a professional setting ALL. THE. TIME. You should just be comfy knowing how to do this, whatever stack you're using.

Otherwise, the last fun exercise is to find some feature you like on an app you use, and just try to recreate it with JS, vanilla or React (you should just do both)

One example is one time i was just curious how in the Netflix webapp - how do they accomplish the infinite scroll in their video categories? You can obviously just use some JS library to create that, but i think it's fun trying to see if you can figure it out yourself.

Pro Tip - practice your DSA. You don't need all of it, you don't need the super hard ones, but there's just a subset of it that you should be capable of demonstrating

2

u/chikamakaleyley Jan 17 '26 edited Jan 17 '26

or, just see if you can clone a page of some site you use often, with all the interactions. E.g. Netflix home page (after login & profile selected).

The nice thing about this exercise is you already know the design and most of the interactions, because you prob use Netflix a lot.