DEV Community

20 Advanced JavaScript Tricks for Experienced Developers

SOVANNARO on February 15, 2025

Welcome to the world of advanced JavaScript! Whether you're a seasoned developer looking to sharpen your skills or an enthusiast eager to dive deep...
Collapse
 
benny00100 profile image
Benny Schuetz

Not quite sure about how "advance-level" those tricks are actually - but nevertheless, it's a good list and I really like the simple and clean examples . Those are really to the point without any unnecessary overload!

Collapse
 
tracygjg profile image
Tracy Gilmore • Edited

Good post but I have three points.
1, #16 is very specific to the Reach JS framework and not a general JS feature, so has limited use.
2, #11 Memorisation can be simplified to:

function memoize(fn) {
  const cache = {};
  return function (...args) {
    const key = JSON.stringify(args);
    if (!cache[key]) {
      cache[key] = fn(...args);
    }
    return cache[key];
  };
}
Enter fullscreen mode Exit fullscreen mode

Further, the if condition could be reduced to the following one-liner, but the code is more difficult to read.

    !cache[key] && cache[key] = fn(...args);
Enter fullscreen mode Exit fullscreen mode

However, it should be mentioned there are limitations with using JSON.stringify to encode the arguments as not all data types can be encoded (BigInt) and there are illegal conditions (circular references.)
3, #20 Custom Elements and Shadow DOM are two of the trio of technologies that comprise Web Components, the third being HTML Templates.

Collapse
 
himanshu_code profile image
Himanshu Sorathiya

To he honest and exact, first 10 are total basic, and can't be considered advance level and also only for experienced devs,
From 11 to 20 you can say that you need prior little experience but they also aren't advance concepts or tricks, but still great list with proper description and example

Collapse
 
ferdnyc profile image
Frank Dana

As others have said, the list starts off pretty beginner-level for something touted as "Advanced JavaScript Tricks for Experienced Developers", but some of the later entries live up to the hype.

Some could use a bit more discussion regarding pros and cons, though. For example, use of Shadow DOM can be a bit controversial because, IIUC, Shadow DOM elements can't be styled with client-side CSS. That may sound like a good thing (web devs maintain full control over their site's presentation), but it defeats the open web's promise of accessibility and customization.

There are plenty of good reasons for end-users to apply custom style rules to online content, and few situations where it's justifiable to include elements which are immune to downstream customization.

Collapse
 
maysanders profile image
May Sanders

A couple of these advanced JavaScript tricks appear more like pointless hacks than best practices, but several are unquestionably helpful. In fact, would experienced developers use this in production code? Additionally, if a company wants to do more than merely use JavaScript, it might be wiser to invest in custom software development services in the long run.

Collapse
 
thefinn15 profile image
Timur

Okay, when we leave from clickbait ? Half or more of list its basic js whats wrong with that experienced developers which dont know about default params, destructuring, arrow fns ? 😂 This article is shit, sry but its true

Collapse
 
yogithesymbian profile image
Yogi Arif Widodo

nice

Collapse
 
wasim_khan_dfe4f6dc379374 profile image
Wasim Khan

Helped !

Collapse
 
lxt profile image
Alexander Thalhammer

I think, you've accidentally concluded twice.