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

Sep 7
Python is MUST in 2025.

This is how to START and MASTER it in 1 year:
0. Preliminary Steps

Before deciding to start, ensure you do these

⬩Know your final goal
⬩Set a target for spending daily 1 hour minimum.
⬩Research about Python ecosystem (libraries, frameworks, code editors).

P.S: This is my personal roadmap. I could spend 1 to 2 hours daily for learning and practicing during 2020. And it took me ~1 year to finish logically. It may differ from person to person.
➊ Start with a bang: Simple Data Types

Schedule: 1st Month
Effort: 1 to 2 hours daily + Normal practice

❯ Boolean
⬩bool
❯ Number
⬩int
⬩float
⬩complex
❯ String
⬩str
❯ Bytes
⬩bytes
⬩bytearray
⬩memoryview
Read 16 tweets
Sep 4
Stanford's Courses on AI & ML (FREE):

❯ CS221 - Artificial Intelligence
❯ CS229 - Machine Learning
❯ CS230 - Deep Learning
❯ CS234 - Reinforcement Learning
❯ CS229M - ML Theory
❯ CS224U - NL Understanding
❯ CS224N - NLP with Deep Learning

All links inside:
1. CS221 - Artificial Intelligence

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

- By Andrew Ng

πŸ–‡ youtube.com/playlist?list=…Image
Read 8 tweets
Sep 1
SAVE THESE SITES FOREVER!!!

Open the thread for all 100+ links:Image
1. Web Development (HTML/CSS/JS)

❯ HTML ➟ web.dev/html
❯ HTML ➟ learn-html.org
❯ HTML ➟ developer.mozilla.org/en-US/docs/Lea…

❯ CSS ➟ web.dev/css
❯ CSS ➟ css-tricks.com/guides
❯ CSS ➟ developer.mozilla.org/en-US/docs/Lea…

❯ JavaScript ➟ web.dev/javascript
❯ JavaScript ➟ developer.mozilla.org/en-US/docs/Lea…

❯ HTML & CSS ➟ theodinproject.com/paths/full-sta…
❯ HTML & CSS ➟ scrimba.com/learn-html-and…

❯ Full Stack ➟ fullstackopen.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
Aug 16
πŸ‘©β€πŸ’» Practice 175+ Algorithms in

❍ C/C++
❍ Java
❍ Python
❍ JavaScript
Or, any language of your choice

Stay in the TOP 5% of programmers!!!
Modern Dev Team relies on coding agents for simple to complex algorithms. But context isn't shared among developers.

ByteRover acts as a central memory layer. Cipher is its open source memory layer.

Know More
β†’ byterover.dev/?source=sw2i
β†’ github.com/campfirein/cip…

Advantages
β€’ Easily share coding memories across your team in real-time.
β€’ Coding memories are generated automatically that scales well.
β€’ No hard-dependency on any IDE. Easily switch between different IDEs.
β€’ Install on any IDE with zero configurations.
➊ Arrays

βž€ Creating an Array
➁ Iterate through Array
βž‚ Get an Element
βžƒ Search an Element
βž„ Insert Element(s)
βž… Delete Element(s)
βž† Filter an Array
βž‡ Fetch a Sub-Array
➈ Merging Arrays
βž‰ Reverse Array
βž€βž€ Rotate Array
Read 20 tweets
Aug 9
Best skills to build in 2025: AI & ML

A complete step-by-step roadmap w/ all free resources: Image
1. Python

Time: 1 month

Focus on Python programming and basic data structures.

⬙ Detailed Roadmap
x.com/swapnakpanda/s…

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

β¬— Introduction to Programming with Python
aupress.ca/books/oer-2023…

β¬— Free Book - Introduction to Python Programming
assets.openstax.org/oscms-prodcms/…

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

β¬– YouTube - Python for Everybody (freeCodeCamp)
youtube.com/watch?v=8Dvywo…Image
2. Mathematics

Time: 2nd & 3rd Month

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

⬙ Free Book
❯ 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
Aug 5
11 FREE Books from MIT for Absolute Beginners

- Machine Learning (ML)
- Deep Learning (DL)
- Reinforcement Learning (RL)
- Artificial Intelligence (AI)Image
Image
Image
Image
1. Foundations of Machine Learning

- A classic book for beginners in ML
- Total 505 Pages

πŸŽ„ cs.nyu.edu/~mohri/mlbook/Image
2. Understanding Deep Learning

- Recently Published (Mar 2025)
- Covered everything about DL
- 541 pages

πŸŽ„ udlbook.github.io/udlbook/Image
Read 12 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!

:(