{ Javascript snippets }

Rich Harris

Rich Harris @Rich_Harris

just learned a neat trick from the Three.js source code: if you want to remove an item from an array whose order doesn't matter, don't do this... array.splice(index, 1); // slooooowwwww ...do this: array[i] = array[array.length - 1]; array.pop(); // orders of magnitude faster!

Jason Beggs

Jason Beggs @jasonlbeggs

🔥 This is a super-handy alias I found out about a while ago. It deletes all the node_modules folders inside your projects. Run this in your sites/code directory and watch your disk space reappear! https://t.co/JECVNWvnuI

R. Alex Anderson ?

R. Alex Anderson ? @ralex1993

??? #JavaScript tip: Reduce an array of constants into an object to save yourself a couple lines of code. I'm using linear interpolation here to create an array of x,y,z values from a location, destination, and the movement time. https://t.co/0wlocaJLWu

Daily Web Dev

Daily Web Dev @dailywebdev

A handy little debugging trick you can use in javascript is throwing exceptions to provide descriptive error messages in the console. throw new Error('hello world') ? You can take this one step further by throwing a variable directly (works with all datatypes) #javascript #js https://t.co/BLm2L6A4Qp

R. Alex Anderson ?

R. Alex Anderson ? @ralex1993

??? Tip: awaiting is an execution-blocking operation, as in the rest of the function won't execute until the awaited promise is resolved. Run promises concurrently by awaiting references to the already executed promises! (You can also do this with Promise.all()) https://t.co/Vp1C6pOXkJ

Katie Hempenius

Katie Hempenius @katiehempenius

How to view your connection speed from DevTools: > window.navigator.connection - This is the "NetworkInformation API" - It returns bandwidth, latency, & connection type approximations? https://t.co/nlCTIWiaTH

JavaScript Teacher

JavaScript Teacher @js_tut

Type in Chrome console: const obj = { } Then type: copy( obj ); Result: const obj = { } will be copied to clipboard. Paste it into your text editor. Works with any currently defined object. Makes debugging a lot easier – used it 1000+ times @ work.