Day 2 of Learning JavaScript 🚀 Today I explored some important JavaScript fundamentals: 🔸Ways to Execute JavaScript: 1️⃣ Inline JavaScript ▫️Written directly inside HTML attributes. Example: onclick="alert('Button clicked')". 2️⃣ Internal JavaScript ▫️Written inside <script> tags within the HTML file. 3️⃣ External JavaScript ▫️Written in a separate .js file and Best practice for real-world applications. ▫️Improves code readability and maintenance. 4️⃣ JavaScript Runtime & Node.js ▫️JavaScript was originally limited to browsers and Browsers use engines like V8 (Chrome) to execute JS. ▫️Node.js allows JavaScript to run outside the browser and it is built using the V8 engine. 🔸Variables in JavaScript: ▫️Three ways to declare variables: ➡️ var ❌ (old, avoid using) ➡️ let ✅ (block-scoped, can't redeclare) ➡️ const ✅ (block-scoped, values that should never change) 📌 Best Practices: ▫️Use camelCase for variables. ▫️Use UPPER_SNAKE_CASE for constants. ▫️Prefer const by default, use let when value changes. 🔸When to Use ✔ const → API URLs, config values, mathematical constants, DOM references. ✔ let → counters, loop variables, form inputs, changing states. Thank you to Harshit T sir #JavaScript #WebDevelopment #NodeJS #Frontend
Learning JavaScript Fundamentals: Execution Methods and Variables
More Relevant Posts
-
🗓️Day 23/100 – Most Important JavaScript Questions Everyone Should Know 🚀 Still learning JavaScript and feeling confused sometimes? Same here. So today I noted down the most important JS questions every learner should understand (not just memorize). 📌 Javascript Question and Answer Q1. What is the difference between var, let, and const? Ans: var is function scoped and can be re-declared. let is block scoped and can be updated but not re-declared. const is block scoped and cannot be updated or re-declared. --- Q2. What is hoisting in JavaScript? Ans: Hoisting means JavaScript moves variable and function declarations to the top of their scope before execution. --- Q3. What is a closure? Ans: A closure is a function that remembers variables from its outer scope even after the outer function has finished executing. --- Q4. Difference between == and ===? Ans: == compares only values (type conversion happens). === compares both value and data type. --- Q5. What is event bubbling? Ans: Event bubbling means an event starts from the target element and moves upward to parent elements. --- Q6. What is scope in JavaScript? Ans: Scope defines where a variable can be accessed in the code. Types: Global, Function, and Block scope. --- Q7. What is a callback function? Ans: A callback function is a function passed as an argument to another function and executed later. --- Q8. What is a promise? Ans: A promise is an object that represents the result of an asynchronous operation. States: Pending, Fulfilled, Rejected. --- Q9. What is async/await? Ans: Async/await is a modern way to handle asynchronous code using promises, making code easier to read and write. --- Q10. Difference between null and undefined? Ans: undefined means a variable is declared but not assigned a value. null means the variable is intentionally set to empty. --- Final Note 💡 Strong JavaScript basics build strong developers. Learning slowly but clearly ✔️ #Day23 #JavaScript #JSInterview #100DaysOfCode #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
Why & How Functions Are Objects in JavaScript 🤯 One of the most interesting (and confusing) concepts in JavaScript is that 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝗮𝗿𝗲 𝗼𝗯𝗷𝗲𝗰𝘁𝘀 👉 Why? JavaScript treats functions as 𝗳𝗶𝗿𝘀𝘁-𝗰𝗹𝗮𝘀𝘀 𝗰𝗶𝘁𝗶𝘇𝗲𝗻𝘀 This means functions can: • Be stored in variables • Be passed as arguments • Be returned from other functions To support all this flexibility, JavaScript internally represents a function as a special type of object. 👉 How? When you create a function, JavaScript actually creates an 𝗼𝗯𝗷𝗲𝗰𝘁 𝗶𝗻 𝗺𝗲𝗺𝗼𝗿𝘆 with: • Executable code (the function body) • Properties (like `name` and `length`) • Methods (like `call`, `apply`, `bind`) • A hidden `[[Prototype]]` linking it to `Function.prototype` That’s why this works 👇 function greet() {} greet.language = "JavaScript"; console.log(greet.language); // JavaScript Here, we’re attaching a property to a function — something only objects can do. #JavaScript #WebDevelopment #Frontend #Programming #SoftwareEngineering #Learning
To view or add a comment, sign in
-
-
✅ JavaScript Output — Why This Date Confuses Almost Everyone This morning’s code was: const date = new Date(2025, 1, 1); console.log(date.getMonth()); console.log(date.getDate()); console.log(date.getFullYear()); 💡 Correct Output 1 1 2025 Now let’s understand why this happens 👇 🧠 Simple Explanation : 🔹 How new Date(year, month, day) really works JavaScript’s Date constructor follows this rule: 👉 Month is ZERO-based That means: 0 → January 1 → February 2 → March … 11 → December So when you write: new Date(2025, 1, 1) JavaScript reads it as: 👉 1st February 2025, not January. 🔹 Line 1: date.getMonth() Since February is internally stored as 1: getMonth() → 1 ✔ Output: 1 🔹 Line 2: date.getDate() This returns the day of the month, and here it is clearly: 1 ✔ Output: 1 🔹 Line 3: date.getFullYear() Year is straightforward: 2025 ✔ Output: 2025 🎯 Key Takeaways : JavaScript months are 0-based Days and years are 1-based new Date(2025, 1, 1) = Feb 1, 2025 This causes many real-world bugs if not remembered 📌 That’s why many developers prefer libraries or careful handling when working with dates 💬 Your Turn Did you expect 1 to mean February? 😄 Comment “Tricky 😮” or “Knew this 👍” #JavaScript #FrontendDevelopment #LearnJS #CodingInterview #Dates #TechWithVeera #WebDevelopment #100DaysOfCode
To view or add a comment, sign in
-
-
Day 2 of Learning JavaScript 🚀 Today I stopped memorizing syntax and focused on actual logic. What I learned (and actually understood, not just “seen”): How arrays of objects work in real use cases Using find() to locate a specific item Using filter() to remove unwanted data Using reduce() to calculate values like total price Writing simple functions instead of messy code I built a basic cart logic: Increase product quantity Remove items with zero quantity Calculate total price dynamically No frameworks. No shortcuts. Just pure JavaScript and logic. I realized one thing today: 👉 If logic is weak, frameworks won’t save you. Tomorrow: more practice, cleaner code, fewer mistakes. #JavaScript #LearningInPublic #WebDevelopment #FrontendDevelopment #Consistency #Day2 #code // Day 2 JavaScript Practice // Topic: Array methods + basic logic let cart = [ { name: "Shoes", price: 1000, qty: 2 }, { name: "Bag", price: 500, qty: 1 }, { name: "Bottle", price: 500, qty: 0 } ]; // Increase quantity of a product function increaseQty(productName) { const item = cart.find(p => p.name === productName); if (item) { item.qty++; } } // Remove items with quantity 0 function removeZeroQtyItems() { cart = cart.filter(item => item.qty > 0); } // Calculate total price function calculateTotal(cartItems) { return cartItems.reduce((total, item) => { return total + item.price * item.qty; }, 0); } // ---- Execution ---- increaseQty("Shoes"); // Shoes qty becomes 3 removeZeroQtyItems(); // Bottle removed const totalPrice = calculateTotal(cart); console.log("Final Cart:", cart); console.log("Total Price:", totalPrice);
To view or add a comment, sign in
-
A new blog has been published on EDUITLEARNING: Introduction to JavaScript. JavaScript is one of the core technologies of the web. This article explains JavaScript from the basics, including how websites work in a browser, why JavaScript was needed, and how it adds interactivity and dynamic behavior to web pages. This post is suitable for beginners who want to understand JavaScript clearly before moving to advanced topics. Read the full article here: 🔗 https://lnkd.in/gRba4yP5 Continue learning with concept-focused content designed to build strong fundamentals. #JavaScript #WebDevelopment #ProgrammingBasics #LearnJavaScript #EDUITLEARNING #TechEducation
To view or add a comment, sign in
-
JAVASCRIPT Tea Episode 1: Javascript Keywords As part of my learning journey in JavaScript, I explored some key keywords and why certain practices are better avoided. JavaScript is the language that brings websites to life, making them interactive, dynamic, and responsive to user actions. At its core, it has a set of keywords that act like the building blocks of your code. They control logic, manage variables, and guide how data flows. Knowing how these keywords work is essential for writing code that’s not just functional, but clean, predictable, and easy to maintain. Here are 15 JavaScript keywords and what they do: 1. let – declares a block-scoped variable. Safer than var. 2. const – declares a constant variable that cannot be reassigned. 3. var – declares a function-scoped variable (older practice, less recommended). 4. if – runs code when a condition is true. 5. else – runs code when the if condition is false. 6. switch – evaluates an expression and runs code based on cases. 7. case – defines a block in a switch. 8. default – fallback code in a switch. 9. for – loop that runs code a set number of times. 10. while – loop that runs as long as a condition is true. 11. function – declares a reusable block of code. 12. return – exits a function and optionally returns a value. 13. break – exits a loop or switch immediately. 14. continue – skips the current loop iteration. 15. try / catch – handles errors; try runs code, catch handles errors. I also learned why using var to declare variables is discouraged in modern Javascript: 1. It is function-scoped, not block-scoped, which can cause unexpected behavior. 2. Hoisting can lead to variables being used before they are declared. 3. You can accidentally redeclare the same variable in the same scope. 4. It makes code less predictable and harder to maintain. Understanding these basics makes writing cleaner, safer, and more efficient JavaScript code. #JavaScript #WebDevelopment #Programming #TechLearning #Coding #SoftwareDevelopment The Curve Africa
To view or add a comment, sign in
-
🚀 JavaScript Prototype — The Hidden Power Behind Objects Most JavaScript developers use objects every day, but very few truly understand what happens behind the scenes. That’s where Prototype comes in 👇 🔹 What is Prototype? In JavaScript, every object has a hidden link to another object called its prototype. When you try to access a property or method: 1️⃣ JS first checks the object itself 2️⃣ If not found → it looks up the prototype chain This mechanism is how inheritance actually works in JavaScript. 🔹 Why Prototype Matters? ✅ Enables code reuse ✅ Saves memory (methods shared, not duplicated) ✅ Core concept behind class, extends, and this 🔹 Example (simple): function User(name) { this.name = name } User.prototype.login = function () { console.log(this.name + " logged in") } const user1 = new User("Rishu") user1.login() 💡 Even JavaScript class syntax is just syntactic sugar over prototypes. 👉 If you understand Prototype, you automatically understand: Inheritance extends & super Prototype chain How JS really works internally 📌 Tip for learners: Don’t memorize — visualize the prototype chain. If you’re learning JavaScript from basic to advanced, Prototype is a topic you must not skip. #JavaScript #Prototype #WebDevelopment #Frontend #LearningInPublic #ChaiAurCode #JSBasics #Programming
To view or add a comment, sign in
-
-
Learning JavaScript in 2025 can feel overwhelming… frameworks everywhere, tutorials everywhere, confusion everywhere So if you’re a beginner, here’s a simple, no-nonsense JavaScript roadmap that actually works: Step 1: Strong Basics (Don’t skip this) • Variables, data types, operators • Conditions & loops • Functions • Arrays & objects Practice daily. Write small programs, not just watch videos. Step 2: Core JavaScript Concepts • Scope & hoisting • Closures • this keyword • Callbacks, promises, async/await This is where most people struggle — spend extra time here. Step 3: DOM & Browser APIs • DOM manipulation • Events • Forms & validations • LocalStorage / SessionStorage Build small projects like: To-Do App Form Validator Quiz App Step 4: Modern JavaScript (Must-know in 2025) • ES6+ features • Arrow functions • Destructuring • Spread/rest operators • Modules Step 5: Real-World Practice • Fetch APIs • Handle errors • Write clean, readable code • Learn debugging (console & browser dev tools) Step 6: Projects > Certificates Build projects that solve real problems. Push everything to GitHub. Explain your code in README files. Step 7: Then pick a direction • Frontend → React / Angular / Vue • Backend → Node.js • Full Stack → MERN / MEAN Don’t rush frameworks without mastering JavaScript first. Consistency beats speed. One hour daily for 6 months > random tutorials for 2 years. If you’re starting JS this year — stay patient, stay curious, and keep building #JavaScript #WebDevelopment #LearningToCode #Beginners #FrontendDevelopment #2025Goals #ProgrammingJourney
To view or add a comment, sign in
-
-
💡 Write Cleaner JavaScript Code `</>` Practical tips to improve your code Clean JavaScript = better readability, fewer bugs & scalable apps 🚀 Agar aap apna JS next level pe le jana chahte ho, toh in modern practices ko follow karo 👇 ✨ 1. Use `let` & `const` (avoid `var`) Block scope = safer & predictable code 🔒 📦 2. Use Object Destructuring Extract values cleanly without repeating object names. 🧩 3. Use Array Destructuring Direct access to values = less code, more clarity. 🧠 4. Use Default Parameters Functions ko safe banao from `undefined` errors ⚠️ 📝 5. Use Template Literals Readable strings with `${}` instead of messy concatenation ✨ 🔄 6. Use Array Methods Prefer `map`, `filter`, `reduce` over loops for cleaner logic 🧹 ⚡ 7. Use Ternary Operator Short & readable conditional statements ✔️ 📌 8. Use Rest & Spread Operators Easily copy, merge & manage data without mutation 🔁 📈 Clean JavaScript helps you: ✅ Write professional code ✅ Reduce bugs ✅ Improve maintainability ✅ Crack better tech interviews 💬 Which JavaScript feature helped you write cleaner code the most? #JavaScript #CleanCode #WebDevelopment #FrontendDeveloper #CodingTips #ES6 #ModernJavaScript #SoftwareDeveloper #Programming #DeveloperCommunity #CodeBetter #LearnJavaScript #Tech 🚀
To view or add a comment, sign in
-
📌 JavaScript Functions Explained Simply A function in JavaScript is a block of code designed to perform a specific task. It helps make your code cleaner, reusable, and easier to maintain. In JavaScript, there are three common ways to define a function: 🔹 1. Function Declaration This is the classic way to define a function. It is hoisted and can be used before it is defined. function sum(a, b) { return a + b; } 🔹 2. Function Expression In this method, the function is assigned to a variable and can be used only after definition. const mul = function(a, b) { return a * b; }; 🔹 3. Arrow Function A modern and concise syntax. It is widely used in modern JavaScript, especially in frameworks like React. const div = (a, b) => { return a / b; }; ✅ Choosing the right type of function depends on your use case, code readability, and project structure. Mastering functions is one of the most important steps in learning JavaScript. 💡 If you are learning JavaScript, understanding functions will make your code much more effective. #JavaScript #JS #Programming #WebDevelopment #FrontendDevelopment #LearnToCode #SoftwareEngineering #CodingTips
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