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

May 13
FREE Certifications fully accepted in the industry:

1. freecodecamp.org/learn/Image
2. University of Helsinki

❯ Python Programming
programming-25.mooc.fi

❯ Data Analysis with Python
courses.mooc.fi/org/uh-cs/cour…

❯ AI
elementsofai.com

❯ DevOps with Kubernetes
devopswithkubernetes.com

❯ Fullstack Web Development
fullstackopen.com

🖇️ All courses: mooc.fi/en/courses/Image
3. Harvard University

❯ Computer Science
cs50.harvard.edu/x/2025/

❯ Python
cs50.harvard.edu/python/2022/

❯ AI
cs50.harvard.edu/ai/2024/

❯ Web Dev
cs50.harvard.edu/web/2020/Image
Read 9 tweets
May 11
I am a Java Developer since 2005.

If I have to start learning it in 2025, I'll follow this:
➊ Fundamental

Effort: 1 to 2 hours daily + Normal practice
Time: 2 weeks

✧ Overview of Java
✧ Setting up [JDK, JRE, IDE]
✧ Basic Syntax and Structure
✧ Primitive Data Types
✧ Variables and Constants
✧ Operators
➋ Control Flow

Effort: 1 to 2 hours daily + Normal practice
Time: 2 weeks

✧ Conditional Statements
❯ if, if else, else if, switch
✧ Loops
❯ while, for, do-while
✧ break and continue
✧ Exception Handling
❯ try, catch, finally
Read 12 tweets
May 8
FREE FREE FREE

9 FREE Books on DSA in Java, C, C++, Python:Image
Image
Image
Image
1. Think Data Structures

- DSA using Java

🔗 greenteapress.com/thinkdast/thin…Image
Image
2. Data Structures and Algorithm Analysis

❯ C++ people.cs.vt.edu/~shaffer/Book/…

❯ Java people.cs.vt.edu/~shaffer/Book/…Image
Image
Read 10 tweets
May 7
Absolute Beginner Friendly Programming Notes

❯ Python
❯ Java
❯ C/C++, DSA
❯ HTML, CSS, JavaScript
❯ SQL
❯ Linux, Git

40 other subjects - 10000+ Pages (💯 FREE)

No signup required. Find links inside.Image
1. Python

- More than 200 Chapters
- 700+ Pages

goalkicker.com/PythonBook/Image
2. JavaScript

- More than 100 chapters
- 400+ Pages

goalkicker.com/JavaScriptBook/

❯ Node.js
goalkicker.com/NodeJSBook/

❯ React
goalkicker.com/ReactJSBook/

❯ React Native
goalkicker.com/ReactNativeBoo…

❯ TypeScript
goalkicker.com/TypeScriptBook…

❯ jQuery
goalkicker.com/jQueryBook/

❯ Angular
goalkicker.com/Angular2Book/Image
Read 10 tweets
May 5
Be an SQL Expert in 2025: A roadmap for absolute beginners
Beginner
⭣ Learn fundamentals ➊
⭣ Working with table ➋
⭣ Working with data ➌
⭣ Querying the data ➍
⭣ Operators ➎
⭣ Functions ➏
⭣ Database objects ➐
⭣ Programming in SQL ➑
⭣ Users and Roles ➒
⭣ Advanced Concepts ➓
Pro
➊ Fundamentals

Effort: 1 to 2 hours per day
Time: 2 weeks

➀ What is a database and DBMS?
➁ What is a relational database?
➂ What are the different vendors for RDBMS?
➃ What is normalization?
➄ Different normalization forms (NFs).
➅ What is SQL?
➆ Different components of SQL.
➇ What is ERD?
Read 14 tweets
May 4
Best skills to build in 2025: AI & ML

Here's a comlete roadmap w/ all free resources:
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/

⬗ 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 for AI/ML

Time: 2 Months

➤ 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

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!

:(