Faisal Akbar's Avatar

Faisal Akbar

@faisalakbar.bsky.social

Full Stack Problem Solver | Data Storyteller in the making | Tech explorer bridging ideas and implementation Currently @ Bank of America Blogging @ dsfaisal.com

26 Followers  |  119 Following  |  36 Posts  |  Joined: 07.02.2024  |  1.8164

Latest posts by faisalakbar.bsky.social on Bluesky

πŸ’‘JavaScript Tips:
Remove duplicates using Set:
const unique = [...new Set([1, 2, 2, 3, 3, 4])] // [1, 2, 3, 4]

22.01.2025 23:50 β€” πŸ‘ 3    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

πŸ’‘JavaScript Tips:
Optional Chaining for Safe Property Access

const user = {
address: {
street: "123 Main St"
}
}
// Old way
const street = user && user.address && user.address.street
// Modern way
const street = user?.address?.street

19.01.2025 18:21 β€” πŸ‘ 0    πŸ” 1    πŸ’¬ 0    πŸ“Œ 0
Post image

πŸ’‘JavaScript Tips:
Nullish Coalescing vs Logical OR

18.01.2025 20:06 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

Common use cases for stacks include:
- Function call management (call stack)
- Undo/Redo operations
- Expression evaluation
- Browser history
- Syntax parsing

05.01.2025 22:47 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

The implementation I provided includes all basic stack operations:
- push(): Add element to top
- pop(): Remove and return top element
- peek(): View top element without removing
- isEmpty(): Check if stack is empty
- getSize(): Get number of elements
- clear(): Remove all elements

05.01.2025 22:47 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

Implementation of stack using JavaScript:

05.01.2025 22:47 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

Key characteristics of a stack:
- Items can only be added/removed from one end (the top)
- The last element added is the first one to be removed
- Access to elements in the middle is not allowed

05.01.2025 22:47 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

πŸš€ Understanding Stack Data Structure

A Stack is a linear data structure that follows LIFO (Last In First Out).

Think of it like a stack of plates - you can only:
1. Add (push) a plate to the top
2. Remove (pop) a plate from the top
3. Look at (peek) the top plate without removing it

05.01.2025 22:47 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

Key benefits:
● Building reusable components with default styles
● Allowing style overrides via props
● Handling conditional classes
● Ensuring Tailwind classes don't conflict

02.01.2025 20:44 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image

Here's a practical example:

02.01.2025 20:44 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

Explanation of cn utility function from #shadcn/ui
The cn function combines two popular utilities:

1️⃣ clsx - For conditionally joining CSS class names
2️⃣ tailwind-merge - For merging Tailwind CSS classes intelligently, removing conflicts

02.01.2025 20:44 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

πŸš€ useTransition() - The performance hook you need:

β€’ Non-blocking state updates
β€’ Background processing
β€’ Loading state management
β€’ Concurrent rendering ready

#react

30.12.2024 22:26 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

🎯 useEffect Cleanup Cheatsheet:

β€’ Timers: clearInterval
β€’ Events: removeEventListener
β€’ Subscriptions: unsubscribe
β€’ Connections: disconnect
β€’ API: cancel request

πŸš€ Why useEffect Cleanup?
No cleanup = Memory leaks
Missing cleanup = Bugs
Bad cleanup = Weird behavior

#ReactJS #javascript

29.12.2024 20:18 β€” πŸ‘ 2    πŸ” 1    πŸ’¬ 0    πŸ“Œ 0

πŸš€ React Hooks: useEffect vs useLayoutEffect

useEffect:
β€’ Runs after paint
β€’ Async, non-blocking
β€’ Use for: data fetching, subscriptions
β€’ Default choice for most cases

useLayoutEffect:
β€’ Runs before paint
β€’ Sync, blocking
β€’ Use for: DOM measurements, preventing flickers
β€’ Performance sensitive

28.12.2024 18:57 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

I use carbon.now.sh

28.12.2024 00:31 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image

It depends, useEffect without deps is perfectly fine if you're not updating state. It will run after every render - that's sometimes exactly what you want. Here are some example:

28.12.2024 00:10 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

🎯 Let's understand useEffect's dependency array in React:

27.12.2024 23:44 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0
Post image

It’s simple, you just need to understand what and when to use dependencies:

27.12.2024 17:51 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

🎯 useEffect() Simplified:

// Run once
useEffect(() => {}, [])

// Run on changes
useEffect(() => {}, [data])

// Run & cleanup
useEffect(() => {
return () => cleanup()
}, [])

No magic, just timing!

#ReactJS #javascript

27.12.2024 17:19 β€” πŸ‘ 6    πŸ” 1    πŸ’¬ 1    πŸ“Œ 0

Yes those are most common use cases.

26.12.2024 18:47 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

πŸ” useRef() Cheat Sheet:

const ref = useRef(initialValue)

3 Things to Remember:
β€’ It's mutable (ref.current)
β€’ Changes are instant
β€’ Won't trigger re-renders

Perfect for:
πŸ“ DOM references
⏱️ Timers
πŸ—ƒοΈ Previous values

#React #JavaScript

26.12.2024 17:57 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

πŸŽ“ React useState() Cheatsheet:

const [data, setData] = useState(initialValue)

3 Rules to Remember:
1. State updates trigger re-renders
2. State updates are async
3. Previous state? Use callback:
setData(prev => prev + 1)

#react #javascript

26.12.2024 04:59 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

🧸 useState() explained to a 5-year-old:

It's like a toy box:
- box = your state
- toys = your data
- replacing toys = setState

When you put in new toys (setState),
React shows everyone your new toys (re-render)!

#React

25.12.2024 20:15 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

πŸͺ React Hooks Explained Simply:

useCallback vs useMemo

useCallback: Memoizes a FUNCTION
const fn = useCallback(() => doSomething(), [deps])

useMemo: Memoizes a VALUE
const value = useMemo(() => computeValue(), [deps])

#React #JavaScript

25.12.2024 03:05 β€” πŸ‘ 2    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0

πŸ“ Tech Interview Prep:

Key difference:
Pass by Value - Function can't modify original (primitive types)
Pass by Reference - Function can modify original (reference types)

24.12.2024 19:37 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image

🌐 JavaScript Pro Tip:
Stop concatenating currency symbols! Use Intl.NumberFormat for proper formatting:
#javascript #webdev

21.12.2024 05:01 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image

JavaScript Tip πŸ’‘:
Two ways to group by JavaScript with zero dependencies:
βœ… using reduce()
βœ… using Object.groupBy()

16.12.2024 02:17 β€” πŸ‘ 1    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image

πŸ’‘JavaScript Tip:
map() is an array method in JavaScript that:
- Creates a new array
- Transforms each element of the original array
- Returns a new array of the same length
- Does NOT modify the original array

11.12.2024 02:49 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image 07.12.2024 19:21 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 0    πŸ“Œ 0
Post image 07.12.2024 19:21 β€” πŸ‘ 0    πŸ” 0    πŸ’¬ 1    πŸ“Œ 0

@faisalakbar is following 19 prominent accounts