🚀 Day 6 of My JavaScript Journey: Scope & Dates Scope controls where variables can be accessed, while Date helps manage time-based operations in real-world applications. Today I learned: 1️⃣ Scope Types: ✔ Global Scope ✔ Function Scope ✔ Block Scope (let & const) 2️⃣ Hoisting behavior with var, let, and const 3️⃣ Date Object & Methods: new Date(), getFullYear(), getMonth(), getDate(), getHours(), getMinutes() 💻 Problems I Solved: 1️⃣ Create variables in different scopes and test accessibility 2️⃣ Format current date into readable format 3️⃣ Extract specific parts like year, month, and day 4️⃣ Build a simple digital time display logic 5️⃣ Understand hoisting differences between var, let, and const 🚀 THE CHALLENGE: Can you guess the output of the following code? function test(){ var x = 10; } console.log(x); (Drop your answer in the comments! 👇) 💡 Takeaway: Proper scope management prevents bugs and makes code secure. Date objects are essential for scheduling, timers, and real-time applications. 📂 SEE IT IN ACTION I’ve added scope examples and date manipulation scripts on my GitHub. Check out the full repository here: 👉https://lnkd.in/dWS4PPfK #JavaScript #WebDev #GitHub #CodingTips #SoftwareEngineering #WebDevelopment #LearningJourney
JavaScript Scope & Date Management Best Practices
More Relevant Posts
-
JavaScript Internals: What Actually Happens with var vs let? Most explanations stop at: • var is function-scoped • let is block-scoped But internally, the difference is deeper. 🔹 Execution Context Creation Phase When JS runs, it creates an Execution Context with: 1️⃣ Variable Environment 2️⃣ Lexical Environment 🔴 How var Works Internally • Stored inside the Variable Environment • Hoisted and initialized with undefined • In global scope, attached to the global object (window in browser) Example: console.log(a); // undefined var a = 10; During memory phase: var a = undefined; 🟢 How let Works Internally • Stored inside the Lexical Environment • Hoisted but NOT initialized • Placed inside the Temporal Dead Zone (TDZ) • Not attached to the global object Example: console.log(b); // ReferenceError let b = 20; Memory is allocated, but access before initialization throws error. 🔥 Key Engine-Level Difference var → Accessible before assignment (value: undefined) → Attached to global object → No block scope let → Hoisted but inaccessible (TDZ) → Block scoped → Not part of global object Understanding this helps in: • Avoiding accidental globals • Preventing hoisting bugs • Writing predictable async code • Debugging production issues JavaScript behavior is not “magic” — it’s execution context design. #JavaScript #FrontendDevelopment #ReactNative #WebDevelopment #ProgrammingInternals
To view or add a comment, sign in
-
Why JavaScript doesn't crash when you call a function before defining it. 🧠 I recently dove deep into the "Execution Context" of JavaScript, and the concept of Hoisting finally clicked. If you’ve ever wondered why this code works: greet(); function greet() { console.log("Hello LinkedIn!"); } ...the answer lies in how the JS Engine treats your code before it even runs a single line. The Two-Phase Secret: Memory Creation Phase: Before the "Thread of Execution" starts, JavaScript scans your code and allocates memory for variables and functions. Functions are stored in their entirety in the Variable Environment. Variables (var) are stored as undefined. Code Execution Phase: Now, the engine runs the code line-by-line. Because the function is already sitting in the memory component, calling it on line 1 is no problem! The Key Takeaway: Hoisting isn't "moving code to the top" (that’s a common myth). It’s actually the result of the Memory Creation Phase setting aside space for your declarations before execution starts. Understanding the "how" behind the "what" makes debugging so much easier. #JavaScript #WebDevelopment #CodingTips #Hoisting #ProgrammingConcepts
To view or add a comment, sign in
-
-
🚀 Day 31–36 of #100DaysOfCode (Catch-up Update) Over the last few days I focused on strengthening my JavaScript fundamentals and problem-solving skills. Topics Covered JavaScript Core Concepts 🔹 this keyword 🔹 Try & Catch (Error Handling) 🔹 Arrow Functions & Implicit Return 🔹 setTimeout() and setInterval() 🔹 Function Expressions 🔹 Higher Order Functions Functions & Scope 🔹 Functions with Arguments 🔹 Return Keyword 🔹 Scope (Block & Lexical Scope) Objects in JavaScript 🔹 Object Literals 🔹 Nested Objects 🔹 Array of Objects 🔹 Math Object 🔹 Random Number Generation 🔹 Built a small Guessing Game Loops & Logic Building 🔹 for loops & while loops 🔹 Nested loops 🔹 break keyword 🔹 Loops with arrays Arrays & Methods 🔹 Array Data Structure 🔹 Array Methods 🔹 indexOf() & includes() 🔹 slice(), splice() 🔹 Concatenation & Reverse Mini Project 🔹 Built a simple Todo App using JavaScript Missed posting updates for a few days, but the learning continued. Still moving forward with the challenge and keeping the momentum. Consistency over perfection. 💻🔥 #100DaysOfCode #JavaScript #WebDevelopment #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
Day 57/100 — The JavaScript Event Loop finally made sense 🔄 For a long time I used setTimeout, Promise, and async/await… but honestly — I never truly understood why JavaScript behaves the way it does. Today I learned about the Event Loop — and everything clicked. JavaScript is single-threaded. So how does it still handle multiple tasks at once? Because of 3 things working together: 🧠 Call Stack – where code runs step by step 📬 Web APIs – timers, DOM events, fetch requests handled outside JS 📋 Callback Queue / Microtask Queue – waiting tasks And the Event Loop keeps checking: “Is the call stack empty? If yes → push the next task.” The biggest surprise for me: console.log("Start"); setTimeout(() => console.log("Timeout"), 0); Promise.resolve().then(() => console.log("Promise")); console.log("End"); Output is NOT what beginners expect: Start End Promise Timeout Because microtasks (Promises) run before macrotasks (setTimeout) 💡 Realization: JavaScript is not slow… I just didn’t understand its scheduling system. Now async code feels predictable instead of magical. Learning fundamentals is like turning chaos into logic. #100DaysOfCode #JavaScript #EventLoop #AsyncJS #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
-
🚀Day 1/100: Diving into Intermediate JavaScript! I’m officially kicking off the #100DaysOfCode challenge! 🎯 For the past 2 months, I have been learning about the basics of HTML, CSS, and JAVASCRIPT also creating mini-projects. Now it is time to dive into intermediate JAVASCRIPT. Today was all about mastering the core ES6+ concepts. Here’s a quick recap of my latest deep dive: ✅ Variable Mastery: Understanding the nuances between var, let, and const (Hoisting vs. Block Scope). ✅ Cleaner Functions: Leveraging Arrow Functions and Default Parameters for more concise, readable logic. ✅ Data Handling: Using the Spread Operator (...) to copy arrays/objects without reference issues and Destructuring to unpack data efficiently. ✅ String Power: Moving from messy concatenation to clean Template Literals. ✅ Object Control: Learning when to use Object.seal() vs. Object.freeze() to protect data integrity. It’s not just about writing code that works—it's about writing code that is clean, scalable, and professional. 💻 #100DaysOfCode #JavaScript #WebDev #IntermediateJS #CodingChallenge #Frontend #SoftwareEngineering #MERNStack #LearningEveryday
To view or add a comment, sign in
-
I thought I understood map(), filter(), and reduce() in JavaScript. Individually, they made sense. But then one small doubt confused me: “If I can use filter() to count employees under 30… why can’t I use it to count how many employees belong to each age group?” That question forced me to stop memorizing definitions and actually understand what these methods do. Here’s what finally made it click for me: • map() → transforms each element (same length output) • filter() → selects a subset (smaller array) • reduce() → builds something new (you decide the final shape) The real shift happened when I stopped asking: “Which method should I use?” And started asking: “What does my final result look like?” Array → Array (same length)? → map() Array → Smaller array? → filter() Array → Object / Number / Anything else? → reduce() I’ve written a short article explaining the full journey — including the exact confusion and how I got clarity 👇 🔗 https://lnkd.in/gbJg9aYt #JavaScript #WebDevelopment #FrontendDevelopment #LearningInPublic
To view or add a comment, sign in
-
JavaScript Array Methods — Small functions, powerful impact. 🚀 As developers, mastering the basics makes our code cleaner, smarter, and more efficient. Here’s a quick refresher: 🔹 map() – Transform each element Perfect when you want a new array with modified values. 🔹 forEach() – Execute a function for each element Great for side effects like logging or updating UI. 🔹 filter() – Select specific elements Use it when you need to narrow down data. 🔹 push() / pop() – Add or remove from the end Simple stack behavior. 🔹 shift() / unshift() – Add or remove from the beginning Useful when order matters. 🔹 reduce() – Convert an array into a single value Powerful for totals, counts, aggregations. Clean code isn’t about writing more — It’s about using the right method at the right time. Strong fundamentals → Better architecture → Scalable systems. What’s your most-used array method? 👇 #JavaScript #WebDevelopment #FrontendDevelopment #CodingTips #SoftwareEngineering #DeveloperLife
To view or add a comment, sign in
-
-
Another productive class today! 💻✨ We dived deep into core JavaScript concepts: 🔁 Closures – understanding lexical scope and how functions remember their environment 🗑️ Garbage Collector – how memory management works behind the scenes 🌐 DOM Manipulation – dynamically interacting with web pages ⏳ Promises – handling asynchronous operations the right way To apply everything practically, we built a To-Do Website Project 📝 — implementing DOM updates, event handling, and async logic in real time. Learning theory is important, but building projects is where real understanding happens. Consistency + Practice = Mastery 🚀 #JavaScript #WebDevelopment #Closures #Promises #DOM #FrontendDevelopment #CodingJourney Chai Code
To view or add a comment, sign in
-
-
💻 Day 81 — Deep Dive Into JavaScript Variables: var, let & const Today's JavaScript learning focused on understanding how variables actually behave behind the scenes. I explored three of the most important building blocks in JavaScript: var, let, and const — and how each one impacts the way we write and structure our code. 🎯 What I Learned / Practiced 🔹 How Browser Treats Variables — var is the oldest way of declaring variables, while let and const were introduced in ES6 to fix problems that var created 🔹 Redeclaration & Reassignment — var can be declared multiple times (which often causes bugs), let can be changed but not redeclared, and const is fixed once assigned 🔹 Hoisting — JavaScript moves certain declarations to the top before execution; var gets hoisted and is accessible early (but with value undefined), while let and const are hoisted but kept in the Temporal Dead Zone, causing errors if accessed too early 🔹 Block Scope vs Function Scope — var follows function-level scope, while let and const follow block-level scope, meaning variables inside { } behave differently depending on how they were declared 💡 Simple Example If you declare a variable with var inside a block like if or for, it becomes accessible outside that block. But if you use let or const, the variable stays confined to that block only. This helps prevent accidental overwrites and keeps code cleaner. 🌱 Reflection / Key Takeaways Today was all about strengthening my core JavaScript understanding. Knowing how var, let, and const behave helps avoid bugs, improves code structure, and makes me a better developer overall. These fundamentals will be very important as I move toward functions, DOM manipulation, events, ES6 concepts, and asynchronous programming. 🔗 Links GitHub:https://lnkd.in/g9fVVxXT Live Demo (Vercel):https://lnkd.in/gAC8YdmP 🙏 Thank you for the continuous guidance and support Codegnan | Uppugundla Sairam | Saketh Kallepu | Ambica Kiranmayee Bellamkonda #Day81 #FullStackDevelopment #FrontendDevelopment #JavaScript #ES6 #WebDevelopment #LearningJourney
To view or add a comment, sign in
-
Day 56/100 – JavaScript Closures (Mind = Blown 🤯) Today I finally understood something that used to scare me: 👉 Closures in JavaScript At first, the word itself sounded complicated. But when I broke it down… it actually made sense. Here’s what I learned: A closure happens when a function remembers the variables from its outer scope, even after the outer function has finished executing. Read that again slowly. It means JavaScript doesn’t “forget” everything when a function ends. Example mindset: One function creates a variable. Another function inside it uses that variable. Even after the outer function is done… the inner function still remembers it. That’s powerful. Why this matters: ✔️ Helps in data privacy ✔️ Useful in counters ✔️ Important for callbacks ✔️ Used heavily in real-world applications Big realization today: JavaScript isn’t just about writing code. It’s about understanding how memory and scope actually work. Some concepts take time. But once it clicks… it feels amazing. Slowly becoming more confident with the fundamentals 💙 #100DaysOfCode #JavaScript #Closures #WebDevelopment #LearningInPublic #FrontendJourney
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