Swapna Kumar Panda Profile picture
Mar 13, 2022 β€’ 25 tweets β€’ 8 min read β€’ Read on X
25 super useful methods in JavaScript

⇩
πŸ’­ Why this thread?

❑ If you have just started learning JavaScript, you might have felt exhausted by seeing so many methods.

❒ If you are simply going through those methods without knowing their use cases, it's going to be tough for you later.

❑ Let's learn use cases.
πŸ“‹ Table of Contents

❑ Array.prototype's

➊ forEach()
βž‹ map()
➌ reduce()
➍ every()
➎ filter()
➏ find()
➐ slice()
βž‘ splice()
βž’ push()
βž“ pop()
➊➊ shift()
βžŠβž‹ unshift()
➊➌ indexOf()
➊➍ findIndex()
➊➎ sort()
❒ String.prototype's

➊➏ toLowerCase()
➊➐ toUpperCase()
βžŠβž‘ substring()
βžŠβž’ indexOf()
20. charAt()
βž‹βžŠ trim()

❑ Math's

βž‹βž‹ floor()
βž‹βžŒ random()

❒ Global

βž‹βž setTimeout()
βž‹βžŽ setInterval()
➊ Array.prototype.forEach()

❍ Use Case

βœ” To iterate through each element in the array
βœ” Perform a task on each element

✘ Not suitable if task is supposed to return some value

✩✩ forEach() is also available in Set.prototype and Map.prototype
βž‹ Array.prototype. map()

❍ Use Case

βœ” To iterate through each element in the array
βœ” Perform a task on each element which returns a value
βœ” Returns a new array with all returned values

✘ Not suitable if task doesn't return any value
➌ Array.prototype.reduce()

❍ Use Case

βœ” To iterate through each element in the array
βœ” Perform a task on each element which accumulates the previous returned value with current element to return a new value

❍ Example

βž€ Sum of all items
➁ Max of all items
➍ Array.prototype.every()

❍ Use Case

βœ” To iterate through elements in the array until a certain condition is not met
βœ” The task performed on each element must return a boolean value

✘ Stops iterating when condition is not met. Hence, it's not suitable for skipping.
➎ Array.prototype.filter()
➏ Array.prototype.find()

❍ Use Case

βœ” To find element(s) which match a criteria
βœ” Use find() to find the first matched element
βœ” Use filter() to find all matched elements

✩✩ filter() returns a new array of matched elements
➐ Array.prototype.slice()

❍ Use Case

βœ” To fetch a sub-array from a larger array

✩✩ slice() returns a new array, doesn't modify the existing array
βž‘ Array.prototype.splice()

❍ Use Case

βœ” To replace a portion of the array with new elements

✩✩ splice() modifies the existing array
Array.prototype's
βž’ push()
βž“ pop()
➊➊ shift()
βžŠβž‹ unshift()

❍ Use Case

βœ” Use push() and pop() to insert/remove elements from the end
βœ” Use shift() and unshift() to insert/remove elements from the start

✩✩ These methods modify the existing array
Array.prototype's
➊➌ indexOf()
➊➍ findIndex()

❍ Use Case

βœ” To find index of the first matched element
βœ” indexOf() does exact match (===)
βœ” findIndex() allows for custom match
➊➎ Array.prototype.sort()

❍ Use Case

βœ” To sort all elements of an array in some order
βœ” Provide a comparator to define custom order
βœ” By default sorting order is lexical

✩✩ This method modifies the existing array
String.prototype's
➊➏ toLowerCase()
➊➐ toUpperCase()

❍ Use Case

βœ” To convert entire string to lowercase alphabets, use toLowerCase()
βœ” To convert entire string to uppercase alphabets, use toLowerCase()

✩✩ These methods returns a new string
βžŠβž‘ String.prototype.substring()

❍ Use Case

βœ” To fetch a part of the string between 2 indexes

✩✩ substring() returns a new string
βžŠβž’ String.prototype.indexOf()

❍ Use Case

βœ” To find the very first occurrence of a "substring" in the original string
βœ” We can also mention from which index the occurrence should be checked
20. String.prototype.charAt()

❍ Use Case

βœ” To fetch the character at a specific position of a string.
βœ” The character fetched is in UTF-16 and returned as a string
βž‹βžŠ String.prototype.trim()

❍ Use Case

βœ” To remove whitespace from both ends of a string

✩✩ trim() returns a new string
βž‹βž‹ Math.floor()

❍ Use Case

βœ” To get the largest integer less than or, equals to the given number
βž‹βžŒ Math.random()

❍ Use Case

βœ” To get a floating point pseudo random number in the range of 0 to less than 1
βœ” It can be multiplied by any number to make a random number being generated in the range of 0 to less than that number
βž‹βž setTimeout()

❍ Use Case

βœ” To execute a function or, piece of code after a timer expires
βœ” The code is executed only for once.

✘ It is an asynchronous function. It shouldn't be used where pausing of execution is intended.
βž‹βžŽ setInterval()

❍ Use Case

βœ” To execute a function or, piece of code repeatedly with a fix time delay

✘ The code is ensured to be executed each time after the time delay. But not "exactly" after the time delay.

✩✩ Cancel further execution using clearInterval()
πŸ’­ Feedbacks

✧ I have picked 25 out of 100s of methods available. My focus was to show you a "learning method" which you may apply wherever you wish.

✧ Share your feedbacks on these. It would definitely help me to share better contents with you.
End of 🧡

If you are a new learner or, someone who finds difficulties in learning JavaScript, you have reached to right person here.

You may like to go through "JavaScript" & "JavaScript Infographics" moments to see what I share regularly.

To never miss any, Follow Me βœ…

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Swapna Kumar Panda

Swapna Kumar Panda Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @swapnakpanda

Jan 29
AI/ML Courses from Stanford (ALL FREE):

❯ CS221 - Artificial Intelligence
❯ CS229 - Machine Learning
❯ CS230 - Deep Learning
❯ CS234 - Reinforcement Learning
❯ CS231N - Deep Learning for CV
❯ CS336 - LLM from Scratch

Course links inside πŸ‘‡Image
Image
Image
Image
1. CS229 - Machine Learning

- By Andrew Ng

πŸ–‡ youtube.com/playlist?list=…Image
2. CS230 - Deep Learning

- 2025 (Ongoing)
- By Andrew Ng

πŸ–‡ youtube.com/playlist?list=…Image
Read 12 tweets
Jan 4
Stanford's ALL FREE Courses (AI & ML):

❯ CS221 - Artificial Intelligence
❯ CS229 - Machine Learning
❯ CS230 - Deep Learning
❯ CS234 - Reinforcement Learning
❯ CS336 - LLM from Scratch
❯ CS224N - NLP with Deep Learning

Course links inside πŸ‘‡Image
Image
Image
Image
1. CS229 - Machine Learning

- By Andrew Ng

πŸ–‡ youtube.com/playlist?list=…Image
2. CS230 - Deep Learning

- 2025 (Ongoing)
- By Andrew Ng

πŸ–‡ youtube.com/playlist?list=…Image
Read 12 tweets
Dec 26, 2025
Best skills to build in 2026: AI & ML

Here's a complete roadmap + all free resources:Image
1. Python

Time: January

Focus on Python programming and basic data structures.

⬙ Detailed Roadmap
x.com/swapnakpanda/s…

β¬— Free Books
❯ Think Python (O'Reilly)
allendowney.github.io/ThinkPython/

❯ Introduction to Programming with Python
aupress.ca/books/oer-2023…

❯ Introduction to Python Programming
assets.openstax.org/oscms-prodcms/…

⬘ Free Course - Harvard CS50
cs50.harvard.edu/python/

β¬– YouTube Courses
❯ MIT Full Course for Beginners
youtube.com/playlist?list=…

❯ Python for Everybody (freeCodeCamp)
youtube.com/watch?v=8Dvywo…Image
2. Mathematics

Time: February & March

➀ Key Topics
✩ Linear Algebra
✩ Single and Multivariable Calculus
✩ Probability & Statistics

⬙ Free Books
❯ Mathematics for Machine Learning
mml-book.github.io/book/mml-book.…

❯ Mathematics for Machine Learning (UC Berkeley)
gwthomas.github.io/docs/math4ml.p…

β¬— More Free Books
x.com/swapnakpanda/s…

⬘ Free Course - Khan Academy
❯ Linear Algebra
khanacademy.org/math/linear-al…

❯ Probability & Stats
khanacademy.org/math/statistic…

β¬– YouTube
youtube.com/@JonKrohnLearnsImage
Read 10 tweets
Dec 25, 2025
11 Python Books for FREE on this Christmas Eve πŸŽ„

Enjoy...Image
Image
Image
Image
1. Think Python

❯ v2 (PDF) greenteapress.com/thinkpython2/t…

❯ v3 (HTML) allendowney.github.io/ThinkPython/Image
2. Clean Code in Python

Publisher: Packt

πŸŽ„ packtpub.com/free-ebook/cle…Image
Read 12 tweets
Dec 12, 2025
Stanford's FREE Courses on AI & ML:

❯ CS221 - Artificial Intelligence
❯ CS229 - Machine Learning
❯ CS230 - Deep Learning
❯ CS234 - Reinforcement Learning
❯ CS336 - LLM from Scratch
❯ CS224N - NLP with Deep Learning

All 11 course links inside:
1. CS221 - Artificial Intelligence

πŸ–‡ youtube.com/playlist?list=…Image
2. CS229 - Machine Learning

- By Andrew Ng

πŸ–‡ youtube.com/playlist?list=…Image
Read 12 tweets
Dec 7, 2025
SITES YOU MUST BOOKMARK FOREVER!!! Image
1. Python, AI & ML, Data Science

❯ Python ➟ realpython.com
❯ Python ➟ fullstackpython.com
❯ Python ➟ planetpython.org

❯ Django ➟ learndjango.com

❯ Flask ➟ blog.miguelgrinberg.com/post/the-flask…

❯ FastAPI ➟ fastapi.tiangolo.com/learn/

❯ Machine Learning ➟ developers.google.com/machine-learni…

❯ Machine Learning ➟ tensorflow.org/resources/lear…

❯ Tensorflow ➟ tensorflow.org/learn

❯ Data Science ➟ towardsdatascience.comImage
2. JavaScript, React, Next, Node.js, Express.js

❯ JavaScript ➟ javascript.info
❯ JavaScript ➟ web.dev/javascript
❯ JavaScript ➟ developer.mozilla.org/en-US/docs/Lea…
❯ JavaScript ➟ theodinproject.com/paths/full-sta…

❯ Node.js ➟ nodejs.org/learn/
❯ Node.js ➟ theodinproject.com/paths/full-sta…

❯ Express.js ➟ developer.mozilla.org/en-US/docs/Lea…
❯ Express.js ➟ expressjs.com/en/starter/ins…

❯ React ➟ scrimba.com/learn-react-c0e
❯ React ➟ theodinproject.com/paths/full-sta…

❯ Next.js ➟ youtube.com/playlist?list=…Image
Read 14 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(