DAY 2 | WHY DID JAVASCRIPT EVEN NEED NEW VARIABLES — WHEN VAR WAS ALREADY THERE? 🤔 Before React, before modern apps, JavaScript had only one way to store values — var. It worked. But as code grew, problems showed up 👇 🔹 values changed without warning 🔹 same variable behaved differently in different places. 🔹 understanding the code became confusing Example: PROBLEM WITH var var count = 10; var count = 20; console.log(count); Output=20. This confusion became a real issue when applications started growing bigger. So in 2015, JavaScript introduced let and const. 👉 let — for values that can change 👉 const — for values that should not change Example: ✅ WITH const const count = 10; const count = 20; console.log(count); Output: Error,count has been already declared This change was not for style. It was to make code clear, predictable, and easier to understand. And this is exactly the kind of JavaScript React depends on. 💬 If this explanation makes sense (or if you see it differently), let’s discuss in the comments. #JavaScript #ReactJS #FrontendDevelopment #WebDevelopment #LearnInPublic #CodingJourney #SoftwareEngineering
JavaScript's let and const: Simplifying Code with Predictability
More Relevant Posts
-
Most beginners jump straight to frameworks like React. I chose to go back to basics with vanilla JavaScript instead. 🧠 I built a Stories app using HTML, CSS & JavaScript (ES5) — not for show, but to strengthen my core fundamentals. No libraries. No shortcuts. Just logic, structure and pure JavaScript. This project helped me sharpen: • DOM manipulation • Event handling • Managing UI state • Writing cleaner, structured ES5 code • Understanding user interactions Sometimes the fastest way forward is to go back to the roots. Master the fundamentals, and frameworks become easier. 👉 Curious to know: What core concept should every frontend developer master before moving to frameworks? 🔗 Live Demo: https://lnkd.in/gSmm2N_g 📂 GitHub: https://lnkd.in/gRVcS5vq #BuildInPublic #JavaScript #FrontendDeveloper #WebDevelopment #LearningJourney #100DaysOfCode #Coding
To view or add a comment, sign in
-
🚀 Starting From Basics Again Before jumping into frameworks like React, I decided to strengthen my core , So I started revising HTML, CSS & JavaScript from scratch. Today, I built a simple Snake Game using pure HTML, CSS, and JavaScript , no libraries, no frameworks. While building this, I focused on: Proper HTML structure Clean and reusable CSS DOM manipulation Game logic implementation High score storage using localStorage What I learned from this: ✔ Fundamentals matter more than frameworks ✔ Logic building is more important than styling ✔ Clean and structured code makes debugging easier ✔ JavaScript feels powerful when you truly understand the DOM Deployed it using GitHub Pages 🔗 Live Demo: https://lnkd.in/dgCyVb4r 💻 GitHub Repository: https://lnkd.in/d3AtuqtF This is just the beginning. Next Moving towards React ⚛️ #WebDevelopment #JavaScript #HTML #CSS #React #LearningInPublic
To view or add a comment, sign in
-
-
Today I built a small JavaScript project where: ✅ Multiple buttons perform different actions ✅ Used forEach to handle events ✅ Created <p> dynamically using JS ✅ Worked with prompt() inputs ✅ Applied arrow functions ✅ Used Date().getFullYear() ✅ Practiced DOM manipulation Each button does something unique, like 👉 Taking user input 👉 Performing calculations 👉 Showing current year 👉 Combining first & last name 👉 Clearing output Slowly improving my JavaScript logic and real-world thinking 💪 #JavaScript #WebDevelopment #FrontendDeveloper #LearningInPublic #CodingJourney #DOM #SheiyansCodingSchool #Kodex
To view or add a comment, sign in
-
-
Are you accidentally slowing down your JavaScript applications? It’s a common mistake I see in code reviews (and one I’ve made myself). When dealing with multiple independent asynchronous calls, it feels natural to just await them one by one. But as the image on the left illustrates, this creates a "waterfall" effect. Your code has to wait for the first operation to finish before it can even start the second one. ✅ The Better Way: Parallel Execution The solution, shown on the right, is Promise.all(). This function takes an array of promises and fires them off simultaneously. Instead of waiting for the sum of all request times (e.g., 2s + 2s = 4s), you only wait for the slowest single request (e.g., max(2s, 2s) = ~2s). This simple change can drastically improve the performance and user experience of your application. A quick rule of thumb: If the data from request A isn't needed to make request B, they should be running in parallel. Have you caught yourself making this mistake? What’s your favorite JS performance tip? Let me know in the comments! 👇 #JavaScript #WebDevelopment #FrontendDeveloper #CodingTips #SoftwareEngineering #PerformanceOptimization
To view or add a comment, sign in
-
-
Are you accidentally slowing down your JavaScript applications? It’s a common mistake I see in code reviews (and one I’ve made myself). When dealing with multiple independent asynchronous calls, it feels natural to just await them one by one. But as the image on the left illustrates, this creates a "waterfall" effect. Your code has to wait for the first operation to finish before it can even start the second one. ✅ The Better Way: Parallel Execution The solution, shown on the right, is Promise.all(). This function takes an array of promises and fires them off simultaneously. Instead of waiting for the sum of all request times (e.g., 2s + 2s = 4s), you only wait for the slowest single request (e.g., max(2s, 2s) = ~2s). This simple change can drastically improve the performance and user experience of your application. A quick rule of thumb: If the data from request A isn't needed to make request B, they should be running in parallel. Have you caught yourself making this mistake? What’s your favorite JS performance tip? Let me know in the comments! 👇 #JavaScript #WebDevelopment #FrontendDeveloper #CodingTips #SoftwareEngineering #PerformanceOptimization
To view or add a comment, sign in
-
-
React Hooks: Where Things Often Go Wrong React hooks are powerful, but many issues I see in codebases don’t come from React itself — they come from how hooks are used. A few patterns that usually cause trouble: • useEffect treated like a lifecycle replacement Not everything belongs in an effect. A lot of logic fits better in event handlers or during render. • Dependency arrays that grow endlessly When an effect depends on “everything,” it’s often a sign that responsibilities aren’t clear. • Effects that shouldn’t exist at all Some effects are only compensating for poor state placement or derived state. • Custom hooks that hide complexity Abstraction is useful, but hiding side effects inside hooks can make bugs harder to trace. • useRef used only for DOM access Refs are also great for storing mutable values that shouldn’t trigger re-renders. My takeaway: Hooks don’t replace good component design. Clear ownership of state and responsibilities makes hooks simpler — and bugs rarer ⚛️ #ReactJS #FrontendEngineering #Hooks #WebDevelopment #JavaScript #EngineeringInsights
To view or add a comment, sign in
-
-
Hello everyone, I’d like to explain two JavaScript concepts—currying and closures—using the dynamic onChange handler in the code snippet below. Here’s a breakdown of how and why it works: 💡 The Concept: Instead of a standard function, we create a function that returns another function. 🧠 What is happening under the hood? 1. Currying (The Setup): We don't pass all arguments (field and e) at once. First, we call handleInputChange('email'). Result: This returns a new function that is sitting there, waiting specifically for the event e. 2. Closure (The Memory): Even after that first function finishes running, the returned function "remembers" the field variable ('email') because of closure. The Payoff: When React finally triggers the onChange event, our inner function executes with access to both the specific field name (saved from the closure) and the event (provided by React). One handler. Infinite inputs. Cleaner code. 🚀 Check out the implementation below. Have you used this pattern in your projects, or do you prefer a different approach? #JavaScript #ReactJS #WebDevelopment #CodingTips #CleanCode
To view or add a comment, sign in
-
-
Why most React developers misunderstand useEffect It's not a lifecycle method. It's not componentDidMount in disguise. And it's definitely not the place for derived state. useEffect is synchronization with an external system. 🔍 The mental model: useEffect = "After React commits to the screen, do this side effect" The dependency array = "Only re-run when THESE values differ" Cleanup function = "Before re-running OR unmounting, clean up" Common pitfall I see: JavaScript // ❌ Wrong: Using useEffect for computed values useEffect(() => { setFullName(`${firstName} ${lastName}`); }, [firstName, lastName]); // ✅ Right: Derived state should be... just stateless computation const fullName = `${firstName} ${lastName}`; useEffect is for: API calls Subscriptions Manual DOM manipulation Analytics/logging Not for: Things you can calculate during render. What's your useEffect horror story? Drop it below 👇 #ReactJS #JavaScript #FrontendEngineering #WebDev #CleanCode
To view or add a comment, sign in
-
There was a time when JavaScript lived only inside the browser. It handled buttons, forms, and small UI interactions. But today, JavaScript runs backend servers, APIs, and real-time applications. What made this possible? Two things: V8 and Node.js. First, V8: Computers do not understand JavaScript directly. They only understand machine code. V8 is a JavaScript engine that converts JavaScript into machine code and runs it very fast. It powers Google Chrome. But V8 alone can only execute JavaScript. It cannot: Read files Create servers Connect to databases Interact with the operating system It is just an engine. Now comes the important part - Node.js. Node.js is not a programming language. It is not a framework. Node.js is a runtime environment. That means it provides an environment where JavaScript can run outside the browser. Node.js takes the V8 engine and adds system-level features like: File system access Networking capabilities Operating system interaction So when you run: node app.js Node.js uses V8 to execute your JavaScript and also gives it the power to act like a backend system. Simple: V8 executes JavaScript. Node.js allows JavaScript to behave like a server. Before Node.js, developers used: JavaScript for frontend Another language for backend Node.js changed that completely. JavaScript was no longer limited to the browser. It became full-stack. That is how JavaScript escaped the browser with the help of V8 and Node.js. #NodeJS #JavaScript #WebDevelopment #BackendDevelopment #FullStackDevelopment
To view or add a comment, sign in
-
-
🚫 Jumping into React too early cost me clarity. When I shifted to a JS-first approach, React stopped feeling complex. React isn’t a separate skill. It’s JavaScript applied to UI with rules around state and re-renders. Here’s what actually made the difference: 1️⃣ Closures Without understanding closures, hooks feel unpredictable. They explain: • Why stale state happens • Why dependencies matter in useEffect 2️⃣ Async JavaScript API calls aren’t React problems. They’re event loop problems. Once I understood promises and async flow, state updates became logical. 3️⃣ Array Methods .map() and .filter() power dynamic rendering. If you struggle with these, JSX becomes messy fast. 4️⃣ Scope & Execution Context • Re-renders are execution cycles • Event handlers are closures • State is captured context None of this is “React magic.” It’s JavaScript. React became easier the moment I stopped “learning React” and started mastering JavaScript fundamentals. Skill sequencing matters. If you're starting in frontend, build language depth before chasing frameworks. What JS concept made things click for you? #JavaScript #React #WebDevelopment #Frontend #LearningInPublic
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development