💡 JavaScript Tip 💡
Making a 'composition function' becomes much more cleaner✨ #javascript#webdevelopment
Here's how👇
Normally while composing functions, you would do this👇which is okay, but when you are using too many functions, the code become hard to read
Follow these steps👇 to make your composition cleaner and more scalable
Step 1⃣
Install a package called 'lodash' in your project.
run 👇 in your terminal
Step 2⃣
Import the function in your JavaScript file
Do this on top of your file👇
Step 3⃣
Write any two(not necessarily) function:
I'm gonna make functions called 'trim' and 'toLowerCase' 👇
Step 4⃣
Call the 'pipe' function by passing all of your func names in their executing sequence. 'pipe' returns a function which takes the input and passes through the series of function in such a way that the result from first function is passed into the next function
Step 5⃣
Now console log the result. You should see this👇
That's all for now.
If you found this helpful, make sure to
1. Like & Retweet the first tweet so others will also learn
💡Git Tip
- What is Alias in #git and why you should know it?
A thread🧵👇
▶️Alias is a term associated with shortcuts in Git.
▶️It compresses longer sequences of commands to make it more meaningful or contain less characters.
Example:
✨Here's how you can make one✨
Open you terminal and type👇
💡#coding tip
Enhance your problem-solving skill by asking Questions.
Here's how👇
1⃣ What information is given in the problem?
- This question will help you to know the problem in depth. You may write bullet points of those info for further reference.
2⃣ What do I know about those information?
- This will help you to know the context of your problem. For instance, the problem may need you to know a mathematical theorem or a programming concept to be solved.