25 powerful methods in JavaScript

https://abs.twimg.com/emoji/v2/... draggable="false" alt="💭" title="Gedachteballon" aria-label="Emoji: Gedachteballon"> Why this thread?

⬘ Are you learning JavaScript? Even if you are experienced, do you ever feel exhausted by the presence of so many methods?

⬙ The best approach to getting familiar is to know the use cases for these.

Here are 25 methods. Let& #39;s discuss their use cases.
The methods are,

➤ Array.prototype& #39;s

➊ forEach()
➋ map()
➌ reduce()
➍ every()
➎ filter()
➏ find()
➐ slice()
➑ splice()
➒ push()
➓ pop()
➊➊ shift()
➊➋ unshift()
➊➌ indexOf()
➊➍ findIndex()
➊➎ sort()
➤ String.prototype& #39;s

➊➏ toLowerCase()
➊➐ toUpperCase()
➊➑ substring()
➊➒ indexOf()
20. charAt()
➋➊ trim()

➤ Math& #39;s

➋➋ floor()
➋➌ random()

➤ Global Methods

➋➍ setTimeout()
➋➎ setInterval()
➋ Array.prototype. map()

➤ Use Case

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> To iterate through each element in the array

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Perform a task on each element which returns a value

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Returns a new array with all returned values

✘ Not suitable if the task doesn& #39;t return any value
➋ Array.prototype. map()➤ Use Casehttps://abs.twimg.com/emoji/v2/... draggable= To iterate through each element in the arrayhttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Perform a task on each element which returns a valuehttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Returns a new array with all returned values✘ Not suitable if the task doesn& #39;t return any value" title="➋ Array.prototype. map()➤ Use Casehttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> To iterate through each element in the arrayhttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Perform a task on each element which returns a valuehttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Returns a new array with all returned values✘ Not suitable if the task doesn& #39;t return any value" class="img-responsive" style="max-width:100%;"/>
➎ Array.prototype.filter()
➏ Array.prototype.find()

➤ Use Case

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> To find element(s) which match a criteria

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Use find() to find the first matched element

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Use filter() to find all matched elements

✩✩ filter() returns a new array of matched elements
➎ Array.prototype.filter()➏ Array.prototype.find()➤ Use Casehttps://abs.twimg.com/emoji/v2/... draggable= To find element(s) which match a criteriahttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Use find() to find the first matched elementhttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Use filter() to find all matched elements✩✩ filter() returns a new array of matched elements" title="➎ Array.prototype.filter()➏ Array.prototype.find()➤ Use Casehttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> To find element(s) which match a criteriahttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Use find() to find the first matched elementhttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Use filter() to find all matched elements✩✩ filter() returns a new array of matched elements" class="img-responsive" style="max-width:100%;"/>
➊➎ Array.prototype.sort()

➤ Use Case

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> To sort all elements of an array in some order

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Provide a comparator to define custom order

https://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> By default sorting order is lexical

✩✩ This method modifies the existing array
➊➎ Array.prototype.sort()➤ Use Casehttps://abs.twimg.com/emoji/v2/... draggable= To sort all elements of an array in some orderhttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Provide a comparator to define custom orderhttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> By default sorting order is lexical✩✩ This method modifies the existing array" title="➊➎ Array.prototype.sort()➤ Use Casehttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> To sort all elements of an array in some orderhttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> Provide a comparator to define custom orderhttps://abs.twimg.com/emoji/v2/... draggable="false" alt="✔" title="Groot vinkje" aria-label="Emoji: Groot vinkje"> By default sorting order is lexical✩✩ This method modifies the existing array" class="img-responsive" style="max-width:100%;"/>
https://abs.twimg.com/emoji/v2/... draggable="false" alt="💭" title="Gedachteballon" aria-label="Emoji: Gedachteballon"> Tasks for you

Find use cases of below

➤ String.prototypes& #39;s
❍ startsWith() / endsWith()
❍ fromCharCode()
❍ padStart() / padEnd()
❍ repeat()
❍ match() / matchAll()
❍ replace() / replaceAll()

➤ Math& #39;s
❍ ceil()
❍ trunc()
❍ round()
Hey https://abs.twimg.com/emoji/v2/... draggable="false" alt="👋" title="Zwaaiende hand" aria-label="Emoji: Zwaaiende hand">

I am a Tech Educator from India https://abs.twimg.com/emoji/v2/... draggable="false" alt="🇮🇳" title="Vlag van India" aria-label="Emoji: Vlag van India">

I am sharing Tutorials, Tips, Infographics, Cheat Sheets, Practice Questions, Project Ideas and Roadmaps on Web Development, DSA and, Database.

To never miss anything, Follow Me https://abs.twimg.com/emoji/v2/... draggable="false" alt="✅" title="Groot wit vinkje" aria-label="Emoji: Groot wit vinkje">
You can follow @swapnakpanda.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: