#javascript tips: 🧙♂️🧙♀️: Asynchronous Iteration in ES2018!
Asynchronous iterators returns a promise for a { value, done } pair. we can now use the await keyword with for … of loops.
#javascript30 #typescript #angular #vue #react #100DaysOfCode #CodeNewbie #developers https://t.co/uLkao6fzFc
Replacing all occurrences of a substring with another string is a common operation.
Unfortunately, doing this correctly is surprisingly hard in JavaScript. 🤯
The new String.prototype.replaceAll API is here to help! 🎉
https://t.co/YYRBRzr1zg https://t.co/zzwqmXQD91
🔥 Super clean little way to disable submit buttons while a form is posting 👌
Just learned that you can reference an input element in the handler by "name" (no long document.querySelector) 🙌
(Video in reply) https://t.co/BqhOETXIq5
#hottip If you need to map over an object in #javascript, used `Object.entries()`. It will convert an object into an array of key/value tuples: https://t.co/YTROMeZ7JR
#JavaScript / #DevTools tip for today:
You can use `await` in the Console without needing to wrap it in an async function. https://t.co/lOLFBMWAZW
🔥 Here is a neat one! Since arrays are objects, we can destructure their indexes to easily grab the first and last items. https://t.co/nfeGmFBcCr
👆🏻Intl is aware of language differences, so it will either detect or be passed a language tag. Swedish uses ä as the 28th letter, so it respects that: https://t.co/pf6agoYxZV
🔥 Use Intl.Collator() to easily sort or group strings regardless of their case or accent https://t.co/MblsezQxGb
🔥 Use Intl.PluralRules() to easily find the ordinal for numbers - 1st, 2nd, 3rd, 4th... https://t.co/RSZKXKtSd0
🔥 Put this in your jest test setup file:
afterEach(() => {
jest.clearAllMocks()
})
Helps ensure your tests are properly isolated.
Little function to remove all the attributes from a DOM element. https://t.co/Cgp2s92yfo
Neat trick: get the last part of a path without fiddling with regexes or libraries. #JavaScript https://t.co/1F7zv4Y769
🔥 When working with #serverless ⚡ it's important to stick to the specific #nodejs version.
Specify it in package.json and test local node before deployment!
#aws #javascript #webdevelopment @goserverless @awscloud https://t.co/LoMGjRCodJ
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!
💡TIP: Serial = one at a time. Parallel = multiple at the same time. You can choose to run things as serial or parallel based on your needs.
#dev #developer #javascript #es6 #nodejs #programming #Developer https://t.co/hG6H3K3iPt
🔥 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
⚡️ Did you know you can use ES6 Object Destructuring to remove one or multiple properties from an Object? https://t.co/ko3r3Nq7jE
? Object destructuring is so powerful. So many good uses, but a "config" object parameter is a great one! https://t.co/dSOCgnF2NN
?? Quick tip:
Clean up your "or" statements with JavaScripts Array.includes()
(Yet another improvement moving from an imperative style to declarative) https://t.co/u8CZHsjyrS
How to Deep Clone an Array ?
There are 2 types of array cloning: shallow & deep. Shallow copies only cover the 1st level of the array and the rest are referenced. For deep clones, go with the JSON way OR better yet use Lodash ?
#100DaysOfCode #CodeNewbie #301DaysOfCode https://t.co/dflJ4XCXOj