r/javascript • • Jul 11 '17

help What 10 Things Should a Serious Javascript Developer Know Right Now?

I'm inviting pure opinion here, but what's your list of ten things that everyone looking for a good javascript role should know and understand. Personally, I'm in a role where what I know is adequate, but I want to be somewhere better; somewhere that has some flippin standards. I'm learning outside of work requirements at the moment, but there is so much shit to learn out there.

The objective is to do good work in a good place.

Narrow it down to your ten for me, or for you.

Can be your own "I must learn x" list too. I'm very interested to hear what people think.

348 Upvotes

223 comments sorted by

View all comments

Show parent comments

42

u/junior-dev Jul 11 '17

Can you source your x2800 claim against document.querySelector?

I can't tell if you're exaggerating or not. 2800 seems too specific to be an exaggeration, so I don't think you are.

I concede that document.getElementById``document.getElementsByTagName and document.getElementsByClassName are faster than document.querySelector and document.querySelectorAll respectively -- by an order of magnitude of 10, and maybe even 100. But not 1000.

I haven't found any evidence for a speed factor of ~2800.

Generally, people are curious about performance, so I've found several JSPerf tests for this.

https://jsperf.com/getelementbyid-vs-queryselector/11

https://jsperf.com/queryselectorall-vs-getelementsbytagname

https://jsperf.com/getelementsbyclassname-vs-queryselectorall/18

In the 2nd one, the difference is quite stark: ~x300 speed increase for document.getElementsByTagName.

But it's not ~2800, none of them are. I understand that these are isolated cases, a bit contrived and unrealistic. But can you come up with any test case that would demonstrate x2800?

I just don't believe it.

1

u/[deleted] Jul 11 '17

2

u/junior-dev Jul 11 '17

2nd Experiment on Chrome 59: x88.2 faster

3rd Experiment on Chrome 59: x27.9 faster

This supports my argument even more. The speed increase is within the 10s, not even 100s, let alone 1000s.

2

u/[deleted] Jul 11 '17 edited Jul 12 '17

The second test shows a difference of 16231.985x in FF52 and a difference of 9248.422x in FF54. Those are some serious WTF numbers and FF54 shows a difference of 6987.384x in test 3.

Some food for thought:

  • The driving distance from Anchorage, AK to Miami, FL is 4976 miles and when divided by 16231.985 is only a quarter of a mile (1618 feet).

  • 1 second times 16231.985 is more than 4.5 hours.

  • It is also the difference between 32 minutes and a year.

  • Or 2.25 days and a century.

  • Or 2 inches and the total height of the Burj Kalifa.

  • Or the difference in mass between the largest recorded blue whale and an average domestic cat.