Swapna Kumar Panda Profile picture
Jan 31, 2022 β€’ 14 tweets β€’ 4 min read β€’ Read on X
🦾 11 Modern JavaScript Hacks

⇩
πŸ“‹ 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".
End of 🧡

Are you looking for modern tricks for web development? I am sharing those on HTML/CSS, JavaScript and React regularly.

If you are interested, 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

Jun 27
FREE FREE FREE

11 Python Books, Absolutely FREEImage
Image
Image
Image
1. Machine Learning with Python

πŸŽ„ python-course.eu/books/bernd_kl…Image
Image
2. Data Structures & Algorithms using Python

This book of 222 pages implements all types of data structures and algorithms.

πŸŽ„ donsheehy.github.io/datastructures…Image
Image
Read 12 tweets
Jun 23
Top 60+ YouTube Courses to learn

- Python
- Java
- C/C++
- JavaScript
- C#
- PHP
- SQL
- RustImage
Image
Image
Image
2. JavaScript

❯ JavaScript
youtube.com/playlist?list=…

❯ JavaScript
youtube.com/playlist?list=…

❯ Node.js
youtube.com/playlist?list=…

❯ Express
youtube.com/playlist?list=…

❯ TypeScript
youtube.com/playlist?list=…

❯ React
youtube.com/watch?v=x4rFhT…

❯ React
youtube.com/playlist?list=…

❯ Next.js 15
youtube.com/playlist?list=…

❯ Next.js 15 & React 19 Projects
youtube.com/playlist?list=…

❯ React Native
youtube.com/playlist?list=…Image
Read 11 tweets
Jun 20
MIT's FREE AI & ML Courses

❯ 6.036 - Machine Learning
❯ 6.S191 - Deep Learning
❯ 6.034 - Artificial Intelligence
❯ 18.05 - Probability and Statistics
❯ 18.06 - Linear Algebra
❯ 18.S096 - Matrix Calculus

All course links inside:
1. 6.036 - Machine Learning

❯ Course Link
openlearninglibrary.mit.edu/courses/course…

❯ YouTube Playlist
youtube.com/playlist?list=…Image
Image
2. 6.S191 - Deep Learning

❯ Course Link
introtodeeplearning.com

❯ YouTube Playlist
youtube.com/playlist?list=…Image
Image
Read 8 tweets
Jun 19
Save these 100+ Sites FOREVER!!!

Open the thread for all the links: 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.com
2. SQL and NoSQL

❯ SQL ➟ sqlbolt.com
❯ SQL ➟ sqlzap.com
❯ SQL ➟ sqltutorial.org
❯ SQL ➟ mode.com/sql-tutorial
❯ MySQL ➟ mysqltutorial.org
❯ PostgreSQL ➟ postgresqltutorial.com
❯ SQL Server ➟ sqlservertutorial.org
❯ Oracle ➟ oracletutorial.com
❯ MongoDB ➟ mongodbtutorial.org
❯ Redis ➟ university.redis.io/academy
❯ Kafka ➟ confluent.io/lp/apache-kafk…
Read 14 tweets
Jun 18
I am a JavaScript Developer since 2005.

If I plan to learn it in 2025, I will do this:
➊ Fundamentals

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

βž€ JavaScript Engine
➁ JavaScript Runtime
βž‚ Execution Context
βžƒ Hoisting
βž„ Call Stack
βž… Event Loop
βž† Callback Queue
βž‹ Variables and, Datatypes

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

βž€ Datatypes
❯ Primitives
❯ Literals
❯ Numeric
❯ Boolean
❯ String

➁ Variable
❯ Naming
❯ Declaration (var, let, const)
❯ Assignment

✧ Special Topic
❯ Type Coercion
❯ undefined, null, NaNImage
Read 17 tweets
Jun 15
FREE FREE FREE

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

πŸŽ„ donsheehy.github.io/datastructures…Image
Image
Image
2. Open Guide to Data Structures and Algorithms

πŸŽ„ pressbooks.palni.org/anopenguidetod…Image
Image
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!

:(