Forum Moderators: open

Message Too Old, No Replies

What have you learned this year in JavaScript?

And what new JS do you plan to focus on learning in 2023?

         

ronin

5:15 pm on Dec 15, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



One of the great gifts of web development (server-side, front-end, container-ised, offline-first etc.) is that there is always something more to learn - and quite often something new to learn, too.

Seven years ago (late 2015), I finally started to get my head around JavaScript. It had taken three goes to get to this point (2000, 2004, 2013) and, as may be apparent, even on the third go, I was two years in before everything eventually (at long last!) started to fall into place...

At that point, I figured it was probably a good idea to start keeping a log of... perhaps not everything I learned, but certainly the key stuff.

Over time, the log evolved such that while in any given month I might learn a handful of new things, one or two of those things might merit highlighting as representing a particularly noteworthy lesson.

And, in amongst that subset of highlighted items, several of those every year might represent a significant broadening of my capability as a web developer.

For the last few years, I've found it helpful to do an end-of-year review to look at all of the new things I've learned. I won't bore you all by reeling out my entire list for 2022, but here are some picks from the top-tier items:

  • Web Audio API (not least on Safari which is... inconsistent with other browsers)
  • ES5 Constructor Functions via the keyword "new" (+ the Reference Objects they build)
  • ES2015+ Classes
  • Graceful JS error handling: try{}, catch(err){}, throw and finally{}


and finally... (the one I'm most excited about):

  • HTML5 Canvas


What new JavaScript have you learned this year?

ronin

7:03 pm on Dec 16, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Oh go on then, I'll add a few more.

I've realised that (apart from Canvas) the items I've listed above - while they're likely the most important things I've got my head around this year - arguably constitute fairly vanilla, fairly uninspiring items.

So I'll add some less essential, but possibly more inspiring JavaScript features I've got my head around in 2022:

  • const isJSON = (str) => {try {JSON.parse(str);} catch (err) {return false;} return true;} is a Boolean check for JSON
  • let myHTML = '©'; const el = document.createElement('textarea'); el.innerHTML = myHTML; myHTML = el.value; will convert HTML escapes
  • sessionStorage is per tab, but may be persisted to a newly opened tab via rel="opener"
  • window.open(url + '?datetime=' + new Date().getTime()) ensures that URLs in new tabs open without a cache
  • in JavaScript (amongst other languages), money needs to be represented as integers (ie. not floats)
  • the JS event keypress is now deprecated and keydown (functionally identical) should be used instead
  • e.key is a newer, improved replacement to String.fromCharCode(e.keyCode)
  • myArray.includes(myString) is a newer, improved replacement to (myString.indexOf(myArray) > -1)
  • the fastest way to shallow-clone an array is let myArrayCopy = myArray.slice();
  • in Javascript, loop labels enable breaking out of multiple loops
  • since 2012, HTML elements with ids automatically become Global Variables in JS
  • e.isTrusted === true will differentiate between user-initiated actions and computational actions like .click()

robzilla

12:21 am on Dec 17, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I haven't coded much this year, but this is some interesting stuff. Thanks for sharing. I tend to forget many of the solutions to obstacles I come across once they're fixed, might pick up that habit of keeping a log in the new year.

Nothing too exciting but something that I'll be working on in the new year is a new ecommerce site and I'm interested in developing UX-friendly ways of product filtering without leaving the page; very few shops and other sites get this right in my experience, so it'll be a fun challenge and a chance to dust off my js skills.

tangor

9:40 am on Dec 18, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Appreciate the head's up!

I try to keep track of what JS is doing, but have been in perl "forever" on what little server side needs I have that I've never implemented js.

Thanks!