JavaScript Tip 💡
Use proper variable names - also in callbacks!
Short, concise code is not necessarily an ideal.
Clarity and readability is.
Paying with an extra line is perfectly ok.
#Javascripttip
Use proper variable names - also in callbacks!
Short, concise code is not necessarily an ideal.
Clarity and readability is.
Paying with an extra line is perfectly ok.
#Javascripttip
JavaScript Tip 💡
Did you know that you can use curly braces with switch-statements?
Takeaways:
🔸 More readable
🔸 Establishes their own block scope
#Javascripttip
Did you know that you can use curly braces with switch-statements?
Takeaways:
🔸 More readable
🔸 Establishes their own block scope
#Javascripttip
JavaScript Tip 💡
The nullish coalescing operator will return its right-hand operand when the left side is *null* or *undefined*. Not just falsy.
When working with numbers, this is typically very useful. #Javascripttip
The nullish coalescing operator will return its right-hand operand when the left side is *null* or *undefined*. Not just falsy.
When working with numbers, this is typically very useful. #Javascripttip
JavaScript Tip 💡
Did you know that you can create your own custom HTML Elements using JavaScript - and then use them in your HTML file just like any other element?
You can create some pretty powerful experiences using this technique. #Javascripttip
Did you know that you can create your own custom HTML Elements using JavaScript - and then use them in your HTML file just like any other element?
You can create some pretty powerful experiences using this technique. #Javascripttip
JavaScript Tip 💡
Did you know that you can use the Broadcast Channel API to do basic communication between browser tabs, windows, and iframes?
It's pretty simple 🙌 #Javascripttip
Did you know that you can use the Broadcast Channel API to do basic communication between browser tabs, windows, and iframes?
It's pretty simple 🙌 #Javascripttip
JavaScript Tip 💡
Use proper variable names - also in callbacks!
Short, concise code is not necessarily an ideal.
Clarity and readability is.
Paying with an extra line is perfectly ok. #Javascripttip
Use proper variable names - also in callbacks!
Short, concise code is not necessarily an ideal.
Clarity and readability is.
Paying with an extra line is perfectly ok. #Javascripttip
JavaScript Tip 💡
The Object.freeze() method freezes an object.
A frozen object can no longer be changed and will result in an error. #Javascripttip
The Object.freeze() method freezes an object.
A frozen object can no longer be changed and will result in an error. #Javascripttip
JavaScrip Tip 💡
Avoid unnecessary async-await.
If the function returns a Promise directly, there's no need to await it. #Javascripttip
Avoid unnecessary async-await.
If the function returns a Promise directly, there's no need to await it. #Javascripttip
JavaScript Tip 💡
By using function composition, you can compose functions for different purposes.
In this case, we're using one function to create different "setter" functions for updating state in React.
#Javascripttip #Reacttip
By using function composition, you can compose functions for different purposes.
In this case, we're using one function to create different "setter" functions for updating state in React.
#Javascripttip #Reacttip
JavaScript Tip 💡
You can set timers using console.time.
This can be useful when debugging slow loops or function calls.
#Javascripttip
You can set timers using console.time.
This can be useful when debugging slow loops or function calls.
#Javascripttip
React Tip 💡
If your component renders the same result given the same props, try wrapping it in React.memo to make them "pure".
This will prevent them from re-rendering, except when their props are changing.
It can potentially give you a great performance boost 🔥
#Javascripttip #ReactTip
If your component renders the same result given the same props, try wrapping it in React.memo to make them "pure".
This will prevent them from re-rendering, except when their props are changing.
It can potentially give you a great performance boost 🔥
#Javascripttip #ReactTip
JavaScript Tip 💡
You can use Object.entries() to iterate through the properties of an object and access both key and value.
No need to do an object lookup for each iteration.
#Javascripttip
You can use Object.entries() to iterate through the properties of an object and access both key and value.
No need to do an object lookup for each iteration.
#Javascripttip
JavaScript Tip 💡
Did you know that JSON.stringify takes a replacer function as its second argument?
You can use it to do filter and replace values when stringifying an object.
#Javascripttip
Did you know that JSON.stringify takes a replacer function as its second argument?
You can use it to do filter and replace values when stringifying an object.
#Javascripttip
JavaScript Tip 💡
Use the property
Here's an example in React
#Javascripttip #Reacttip
Use the property
valueAsNumber
to get the numeric number from an input field through an event.Here's an example in React
#Javascripttip #Reacttip
JavaScript Tip 💡
Instead of using find(), or manually searching a list for an occurrence, use the array method some() instead.
It’s built for exactly that purpose.
#Javascripttip
Instead of using find(), or manually searching a list for an occurrence, use the array method some() instead.
It’s built for exactly that purpose.
#Javascripttip