Swapna Kumar Panda Profile picture
Mar 17, 2022 16 tweets 5 min read Read on X
🦾 11 Modern JavaScript Hacks

💭 Why is this Thread?

❑ The code we write should be readable and, maintainable. But that doesn't mean it should be verbose.

❒ With ECMAScript new specifications, many newer syntaxes are available which we should try to use mostly.

❑ Let's explore few such modern tricks.
📋 Table of Contents

➊ Conversion to Number
➋ Conversion to Boolean
➌ Conversion to String
➍ Complex String
➎ Short Circuit && / ||
➏ Nullish Check
➐ Default Value
➑ Default Function Parameter
➒ Optional Chaining
➓ Array Resizing
➊➊ Function Rest Parameter
➊ Conversion to Number

To convert any data to a Number type, use

⇥ Unary "+" operator
⇥ Number function
⇥ parseInt function
➋ Conversion to Boolean

To convert any data to a Boolean type, use

⇥ Boolean function
⇥ !! operator (Double Bang Operator)
➌ Conversion to String

Are you converting a value to a String like below? Remember, it's faulty.

⇥ "" + input

Instead use String() function.
➍ Complex String

Are you forming a String using multiple concatenation operators? Remember, it's difficult to write and hard to read.

⇥ 'Hello ' + fName + ' ' + lName

The modern approach is to use String Template Literals.

⇥ `Hello ${fName} ${lName}'
➎ Short Circuit && / ||

Are you still using "if" statements for one-liners?

⇥ if (hungry) eat()

The modern approach in such scenarios is to use Short-Circuits.

⇥ hungry && eat()
➏ Nullish Check

How do you check Nullish values?

The modern and most effective way is doing it using "Nullish Coalescing Operator" (??)
➐ Default Value

How do you assign value to a variable if it's missing?

⇥ x || (x = 10)
⇥ y ?? (y = 10)

The modern approach of doing it is

⇥ x ||= 10
⇥ y ??= 10
➑ Default Function Parameter

Do you often check if a function parameter is missing its value and manually assign a value to it?

The modern approach is to use default function parameters.
➒ Optional Chaining

To avoid TypeError, instead of checking whether a property exists in an object manually, use "Optional Chaining Operator" (?.)
➓ 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.
➊➊ Function Rest Parameter

Are you using "arguments" variable to manipulate your function parameters? The modern approach is to use a "rest parameter".
⚠️ Repost Notice ⚠️

⬘ Though this is my original work, most of these tricks are previously shared by me in [CHIRPBIRDICON]

⬙ If you liked this content and do feel others might learn from it, please support.
End of 🧵

Hey 👋 I am a Tech Educator from India 🇮🇳

I am sharing Tutorials, Tips, Techniques, Infographics, Cheat Sheets, Interview Questions and Roadmaps on Web Development, DSA and, Database.

Are you interested? I am sure, you are.

To never miss anything, 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!

:(