🚀 Day 14:– JavaScript + DSA (Java) & DSA Progress Today was a productive learning day! 🔹JavaScript Concepts Learned: I explored how JavaScript code actually works behind the scenes. ✅ JavaScript is a synchronous(Synchronize means ek ke baad ek), single-threaded language — it executes one command at a time in a specific order. ✅ Learned about the Execution Context: When a JavaScript program runs, a Global Execution Context is created. It has two phases: Memory Creation Phase Code Execution Phase ✔ In the memory phase, variables are stored as key–value pairs. ✔ If a variable is declared using var, it is allocated memory and initialized with undefined. ✔ Accessing a var variable before initialization results in undefined due to hoisting. ✅ Understood the Temporal Dead Zone (TDZ): Variables declared with let and const are hoisted but not initialized, and accessing them before declaration throws an error.(jab koi bhi variable temporal deadzone ke andar hota hai then hum usko access nahi kr sakte) ✅ Learned how the Call Stack works: How execution contexts are pushed into the stack How the stack grows and shrinks during function calls Understanding the Global Execution Context and Function Execution Context clearly hosting says that jo bhi aapke variable hai code me unka decleration top pr chala jayega 🔹 DSA (Java) Progress: 💻 Solved LeetCode Problem #78 – Subsets Also practiced finding the Greatest Common Divisor (GCD) using recursion (Euclidean Algorithm). #JavaScript #WebDevelopment #DSA #Java #LeetCode #LearningJourney #100DaysOfCode
JavaScript & DSA Progress: Execution Context & Call Stack
More Relevant Posts
-
Is JavaScript really an interpreted language? JavaScript is often described as an interpreted language but modern JS engines like V8 actually compile before executing it. To answer this question, I created blog that explains the following: 1) What is Compiler, interpreter and JIT Compiler 2) Understanding the behavior of JavaScript 3) Background of JS Engine 4) How JS engine utilize JIT Compilation Read here 👇 https://lnkd.in/dj4ecJA4 #javascript #webdev #softwareengineering #programming
To view or add a comment, sign in
-
Today I refreshed my JavaScript fundamentals by reading the Basic Syntax and Comments section from the Mozilla documentation. JavaScript is case-sensitive. Variables can be declared using three keywords: var, let, and const. Variables can exist in different scopes depending on context (global, function, or block scope). let and const are block-scoped (inside "{ }"). Variables should always be declared before they are used. var and let declarations can be created without initialization, and their value will be "undefined". const must always be initialized at the time of declaration. JavaScript supports destructuring syntax to unpack values, for example: const { bar } = foo Variable Hoisting allows declarations to be recognized before execution in their scope. However, let and const exist in a Temporal Dead Zone (TDZ) until they are declared. Reference: https://lnkd.in/erP86tnF #javascript #fundamentals
To view or add a comment, sign in
-
JavaScript Doesn't Have Classes! Yes, that's correct. Anyone who started using JavaScript after 2015 will be very confused by this statement. "But I saw the class syntax in the intro course I took when I started programming!" Which would also be accurate. JavaScript has a syntax for classes, but under the hood, no class in the Java/C++ sense is being declared. Don't believe me? Go run this in your browser console: class Test { constructor() { this.prop = "test"; } } console.log(typeof Test); Yes, it's a function. JavaScript classes essentially do two things: create a constructor function that works with the "new" keyword, and set up a prototype object (more on that another time). "Okay, but it's still basically a class." No, not really. Try this code (hopefully you tried the one above first): let x = new Test(); Now you have a Test object with one property, "prop". Now do this: x.newprop = "newprop"; This runs. In most other languages, this would be grounds for the compiler to crash your IDE out of pure spite. It runs in JavaScript because the class was never acting as a blueprint, it was just a special constructor function all along. If you've always been confused by the __proto__ property when checking Javascript objects and too scared to ask what it is, well it's part of the same conspiracy, I will be writing about it in my next post #javascript #webdevelopment #programming
To view or add a comment, sign in
-
-
I have started a challenge today to finish Javascript in 1 week. #DAY1 ✨ Today I have done these basic questions of Java Script. Print your name, age Create variables and check typeof 1. Print Name & Age let name = "Rahul"; let age = 21; console.log("Name:", name); console.log("Age:", age); Output Name: Rahul Age: 21 2. Check typeof of Variables let name = "Rahul"; let age = 21; let isStudent = true; console.log(typeof name); // string console.log(typeof age); // number console.log(typeof isStudent); // boolean 3. More typeof Examples let x; let y = null; let arr = [1, 2, 3]; let obj = {a: 1}; console.log(typeof x); // undefined console.log(typeof y); // object (important JS bug ⚠️) console.log(typeof arr); // object console.log(typeof obj); // object typeof null = "object" kyun aata hai typeof null = "object" ❓ (Why?) JavaScript let y = null; console.log(typeof y); // object 👉 Expected kya hona chahiye? "null" 👉 But actual output aata hai: "object" 💡 Reason (Simple Explanation) Ye JavaScript ka old bug hai, jo aaj tak fix nahi hua. 🔧 Internal reason: Jab JavaScript banayi gayi (1995 me), us time pe: Values ko binary format me store kiya jata tha Objects ka type code = 0 hota tha null ka representation bhi 0 tha 👉 Isliye: null → object treat ho gaya ❌ ⚠️ Important Point Ye bug hai, feature nahi But ab isse change nahi kar sakte (backward compatibility issue) 🧠 Interview / Exam Line In JavaScript, typeof null returns "object" due to a historical bug in the language, where null was incorrectly classified as an object. ✅ Correct Way to Check null let y = null; if (y === null) { console.log("y is null"); } 👉 Always use: === null #coding #consistency #CS #practice
To view or add a comment, sign in
-
While learning JavaScript deeply, I came across a concept that completely changed how I think about variables. In JavaScript, variables don’t have types — values do. Unlike languages like Java or C++, where a variable’s type is fixed, JavaScript variables are just containers that can reference different kinds of values over time. Example: let x = 10; // number x = "hello"; // string x = true; // boolean The variable x stays the same, but the value (and its type) changes. Understanding this simple idea makes many JavaScript behaviors — like dynamic typing and type coercion — much easier to reason about. I wrote a short post explaining this concept clearly. Check it out here: https://lnkd.in/gMZ-ESa3
To view or add a comment, sign in
-
-
Day 19 :-JavaScript + DSA (Java) After a short health break, I’m back again with full focus and energy to continue my daily learning journey. Consistency is the key, and today the journey continues stronger than before. 💪 📌 Today’s Learning JavaScript – DOM Manipulation 🔹 Creating Nodes ->createElement() – Create a new HTML element ->createTextNode() – Create a text node ->createAttribute() – Create an attribute node 🔹Accessing Attributes ->getAttribute() – Get the value of an attribute ->setAttribute() – Set or update an attribute ->removeAttribute() – Remove an attribute 🔹Adding Nodes to the DOM ->appendChild(node) – Adds a node as the last child ->append(node1, node2, …) – Adds multiple nodes ->insertBefore(newNode, referenceNode) – Insert before a specific node ->prepend() – Adds a node at the beginning ->replaceChild() – Replace an existing child node 🔹Other DOM Methods ->innerHTML – Directly set or update HTML content ->insertAdjacentHTML() / insertAdjacentElement() with positions: ->beforebegin ->afterbegin ->beforeend ->afterend ->removeChild(node) – Remove a child node ->element.remove() – Remove the element directly from the DOM 📌 DSA Learning ->Today I studied the Count Inversion Pair problem. Brute Force Approach: ->Time Complexity → O(n²) Optimized Approach (Using Merge Sort): vTime Complexity → O(n log n) #100DaysOfCode #JavaScript #WebDevelopment #DSA #LearningInPublic #Consistency
To view or add a comment, sign in
-
Coming from languages like C/C++ or Java, JavaScript can feel a bit like magic. There’s no dedicated, pre-run compiler—everything happens on the fly! So, what actually happens under the hood when a simple JavaScript program runs? 1. The Translation Phase (From Code to Machine Language) Parsing: The engine's parser checks for syntax errors, breaks the code into tokens (keywords, Identifiers, operators, etc.), and builds a tree structure called the Abstract Syntax Tree (AST). Interpretation: The engine translates the AST into Bytecode (an intermediate language) and execution starts immediately using this Bytecode line-by-line. JIT Compilation: As the Bytecode runs, a "Profiler" watches the code. If it notices a specific function is being used over and over again(called "hot" code), it passes that specific bytecode to the JIT Compiler. 2. Where Does Everything Live? (Memory) While the program is loaded into RAM, memory is split into two main areas: The Heap: Stores complex reference types (Objects, Arrays, Functions) and program data. The Stack: Stores primitive values, memory references (addresses), and the Execution Contexts. 3. The Execution Phase (How it Runs) Whenever a JS program runs, a Global Execution Context (GEC) is pushed onto the Call Stack. JS engine is single-threaded, meaning it executes synchronously, line-by-line. The GEC creation happens in two distinct phases: 🧠Memory Creation Phase: The engine scans the code and allocates memory. Functions get their complete bodies stored. Variables declared with var are initialized as undefined, while let and const variables are placed in the Temporary Dead Zone (TDZ). 💻 Code Execution Phase: The engine executes the program top-to-bottom. Whenever a new function is invoked, a brand new Execution Context is created and pushed onto the Call Stack to handle it! Have you ever looked into how your favorite programming language executes under the hood? Let me know in the comments! 👇 #JavaScript #WebDevelopment #CodingJourney #JSEngine #SoftwareEngineering #TechTips#
To view or add a comment, sign in
-
-
The Day I Realized "Car" and "Carpet" Aren't the Same Thing I still remember the early days when I looked at a textbook like this and thought, "Yeah, that makes sense. Java is just the formal name for JavaScript, right?" Spoiler alert: I was very, very wrong. 💀 I walked into my first project thinking I could just "shorten the name" and everything would be fine. It took exactly one NullPointerException and a failed npm install for me to realize that thinking Java and JavaScript are related is like: Thinking Ham and Hamster are the same food. (Don't eat the Hamsters people!) Thinking a Pine tree and a Pineapple are the same plant. 🍍 Thinking Car and Carpet will both get you to work on time. 🏎️ (Unless you are "Alladin" 😂😂) For those who are still in the "Wait, they aren't cousins?" phase, here is the quick breakdown I wish I’d had: The Origin Story: JavaScript was named "JavaScript" purely as a 1995 marketing stunt to piggyback on Java's popularity. (Narrator: It worked too well). Java is a compiled, statically-typed language that runs on the JVM. JavaScript is an interpreted, dynamically-typed language that (mostly) runs in the browser. Java is like building a skyscraper with a strict blueprint. JavaScript is like building a LEGO set while the instructions are still being written. The Lesson: Never trust a book that puts "(or Java)" in parentheses unless you want your codebase to spontaneously combust. 🚩 To all the junior devs out there: it’s okay to be confused! Just remember, one runs your Android apps, and the other probably broke your CSS at 2:00 AM. 😁 . What was the "obvious" tech fact you totally misunderstood when you first started coding? Let's share some embarrassing stories in the comments! 👇 Educative Resource: https://lnkd.in/d8GMSEQH #SoftwareEngineering #DeveloperHumor #CodingLife #ProgrammerProblems #TechCommunity #JavaScript #Java
To view or add a comment, sign in
-
-
I used to confuse ... in JavaScript all the time. Until I realized it’s doing two completely opposite things. That’s when everything finally clicked. When I started learning JavaScript, I saw this everywhere: ... And I thought: “Okay… same operator, same job.” Wrong. Here’s the truth 👇 The same syntax has two different roles: → Spread = expands data → Rest = collects data 💡 Think of it like this: • Spread → unpacks • Rest → packsat small mental shift changed how I write JavaScript. No more confusion. Just clarity. If you're learning JS right now, remember this: 👉 Don’t memorize syntax 👉 Understand behavior That’s what actually sticks. I found this visual guide super helpful 👇 What’s one JavaScript concept that confused you at first but makes sense now? 💬 Hitesh Choudhary | Piyush Garg | Akash Kadlag | Suraj Kumar Jha | Shubham Waje | Jay Kadlag #chaicode #JavaScript #WebDevelopment #CodingJourney #LearnToCode #Developers #Programming #100DaysOfCode #TechLearning
To view or add a comment, sign in
-
-
🚀 Day 22 :- JavaScript + DSA (Java) 💻 JavaScript – Event Listeners I explored how websites respond to user actions using event listeners. Mouse Events click – triggers when a user clicks on an element dblclick – triggers when a user double-clicks on an element mouseover – triggers when the mouse pointer enters an element mousemove – triggers whenever the mouse moves inside an element Keyboard Events keydown – triggers when a key is pressed down keyup – triggers when a key is released Event Object The event object provides information about the interaction happening in the browser: event – the main object created when an event occurs event.target – the element that triggered the event event.type – the type of event that occurred event.key – shows which keyboard key was pressed event.clientX – horizontal mouse position in the viewport event.clientY – vertical mouse position in the viewport 🧠 Java (DSA) Today I learned about Cyclic Sort and solved : LeetCode Problem #268 – Missing Number (using 4 different approaches): 1️⃣ Sorting Approach :- Used built-in sorting and then checked which index didn’t match the value. 2️⃣ Boolean Array Approach : Used an extra boolean array to mark numbers that appear and find the missing one. 3️⃣ Mathematical (Sum) Approach: Applied the formula for the sum of first n numbers and subtracted the array sum. 4️⃣ Optimal Approach (Follow-up Requirement) : Solved it with Time Complexity: O(n) and Space Complexity: O(1). Learning multiple approaches to the same problem really helps strengthen problem-solving skills. #Day22 #JavaScript #DSA #Java #LeetCode #CodingJourney #100DaysOfCode
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