Swapna Kumar Panda Profile picture
Oct 13, 2021 12 tweets 4 min read Read on X
🔥 9️⃣ Useful Hacks to simplify your JavaScript code

Follow these simple yet most useful hacks in your code. These are not only modern way of writing JS code but also minifies your code.

🧵 👇
We will cover,

1️⃣ Converting to Boolean
2️⃣ Converting to Number
3️⃣ Converting to String
4️⃣ Short-Circuit && and ||
5️⃣ Default Function Parameters
6️⃣ Nullish Coalescing Operator
7️⃣ Optional Chaining Operator
8️⃣ Array Resizing
9️⃣ Converting Array-Like to Array
1️⃣ Converting to Boolean

To convert any data to a Boolean type, use

→ Boolean function or,
→ !! operator
2️⃣ Converting to Number

To convert any data to a Number type, use

→ + operator or,
→ Number function or,
→ parseInt function
3️⃣ Converting to String

Use String function when you need to convert any data to a String type.
4️⃣ Short-Circuit && and ||

Instead of using traditional if-condition statements, try to use short-circuit && or, ||

Use this trick only when the expression inside "if" is just a one-liner expression or a simple function.
5️⃣ Default Function Parameters

To assign missing values on function parameters, instead of using || operator, use default function parameters.
6️⃣ Nullish Coalescing Operator

Instead of manually checking whether an input is either null or, undefined, use nullish coalescing operator (??).
7️⃣ Optional Chaining Operator

To avoid TypeError, instead of checking whether a property exists in an object manually, use optional chaining operator (?.)
8️⃣ Array Resizing

To remove few last elements from an array, simply modify the array's length property value. Items from the array will automatically be removed.
9️⃣ Converting Array-Like to Array

An Array-Like object is like an Array which has a length property and, can be iterated like an array.

E.g., arguments inside function body, a string object etc.

Use Array.from() or, spread operator to convert Array-Like to an Array.
That's it guys. Did you find these hacks useful and interesting?

Reply any additional hacks you are aware of. Share me your feedbacks as well.

See you in next 🧵 soon. 👋

• • •

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

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
Aug 4
Best YouTube Channels for Programming

❯ C ➟ J*** S**
❯ C++ ➟ T**C**
❯ Python ➟ *or** S**
❯ Java ➟ *el***
❯ JavaScript ➟ t**S**
❯ C# ➟ *u*v***
❯ Rust ➟ F** C**

Links inside:Image
❯ C ➟ Jacob Sorber
youtube.com/@JacobSorber

❯ C++ ➟ TheCherno
youtube.com/@TheCherno

❯ Java ➟ Telusko
youtube.com/@Telusko

❯ Python ➟ Corey Schafer
youtube.com/@coreyms

❯ JavaScript ➟ tapaScript
youtube.com/@tapasadhikary

❯ Node.js ➟ Codevolution
youtube.com/@Codevolution

❯ Golang ➟ Alex Mux
youtube.com/@mr_mux408

❯ C# ➟ kudvenkat
youtube.com/@Csharp-video-…
❯ SQL ➟ techTFQ
youtube.com/@techTFQ

❯ SQL ➟ DataWithBaraa
youtube.com/@DataWithBaraa

❯ Rust ➟ Francesco Ciulla
youtube.com/@francescociul…

❯ PHP, Laravel ➟ The Codeholic
youtube.com/@TheCodeholic

❯ Swift ➟ CodeWithChris
youtube.com/@CodeWithChris

❯ Kotlin ➟ PhilippLackner
youtube.com/@PhilippLackner

❯ Ruby ➟ DriftingRuby
youtube.com/@DriftingRuby

❯ R ➟ marinstatlectures
youtube.com/@marinstatlect…

❯ TypeScript ➟ basarat
youtube.com/@basarat
Read 4 tweets
Aug 3
Python is a MUST in 2025.

This is how to START and be an EXPERT 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. And it took me ~1 year to finish. 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
Jul 30
MIT's FREE Courses on Mathematics:

❯ 18.01 : Single Variable Calculus
❯ 18.02 : Multivariable Calculus
❯ 18.06 : Linear Algebra
❯ 18.05 : Probability and Statistics
❯ 6.042J : Mathematics for Comp Sc
❯ 18.404J : Automata Theory

Course links inside:
1. 18.01 - Single Variable Calculus

❯ Course Link
ocw.mit.edu/courses/18-01-…

❯ YouTube PlayList
youtube.com/playlist?list=…Image
Image
2. 18.02 - Multivariable Calculus

❯ Course Link
ocw.mit.edu/courses/18-02-…

❯ YouTube PlayList
youtube.com/playlist?list=…Image
Image
Read 8 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!

:(