💛💻 #Day49 – JavaScript Journey Begins 🚀 🔥 Day 1: Introduction to JavaScript 🎯 Today’s Learning Topic: JavaScript Basics 🟡 1️⃣ What is JavaScript? JavaScript is a lightweight, interpreted scripting language used to add behavior, interactivity, and functionality to web pages. Key Features: 🧠 Scripting Language → Browser handles compilation & execution ⚡ Lightweight → Requires less code & memory 🧩 Interpreted → Executes line by line for easy debugging 🟣 2️⃣ History of JavaScript 📅 Introduced in 1995 by Brendan Eich at Netscape 🏷️ Originally named Mocha → LiveScript → JavaScript ⚠️ Note: Java ≠ JavaScript (Both are Object-Oriented, but different languages) 💚 3️⃣ Why JavaScript? ✅ Works on both Front-end & Back-end ✅ No special setup needed ✅ Powers fast, dynamic websites ✅ Used in Mobile, Desktop, and Game Development ✅ High career demand ✅ Supports frameworks like: 🔹 Angular 🔹 React 🔹 Node.js 🔹 Vue.js 🔹 jQuery 🧡 4️⃣ Features of JavaScript Scripting Language – Easy to use in browsers Lightweight – Fast and efficient Dynamically Typed – No need for type declarations Object-Oriented – Uses objects & classes Platform Independent – Write once, run anywhere (WORA) Interpreted Language – Executes line by line Event-Driven – Reacts to user actions 💙 5️⃣ Applications of JavaScript 💡 Client-side validation (forms) 🧩 HTML DOM manipulation 🔔 Pop-ups & alerts ⚙️ Backend communication (AJAX) 🌐 Server-side apps (Node.js) ❤️ 6️⃣ How to Write JavaScript in HTML Ways to include JS in HTML: i. In Head Section <script> // JavaScript code here </script> ii. In Body Section <script> // JavaScript code here </script> iii. External File <script src="external.js"></script> 🌈 📂 GitHub Live Link: 👉 🔗 https://lnkd.in/g6k_NFXM 💬 Starting my JavaScript learning journey from today! I’ll be sharing daily updates on concepts, syntax, and mini projects — from beginner to advanced level. Let’s code the web together! 🌐✨ 🔖special thanks to Harish Harish M, Spandana Chowdary, 10000 Coders #JavaScript #JavaScriptLearning #WebDevelopment #FrontendDevelopment #CodingJourney #LearnToCode #100DaysOfCode #TechCommunity #WebDesign #HTML #CSS #ProgrammerLife #JS #Developers #SoftwareEngineering #FullStackDeveloper #CodingDaily #CodeNewbie #WebDevCommunity #WomenWhoCode #ReactJS #NodeJS #VueJS #Angular #GitHub #ProgrammingLife #WebApps #CodeChallenge #TechLearning #ShanmukhaLearns
"JavaScript Basics: Introduction, History, Features, Applications, and Writing in HTML"
More Relevant Posts
-
Don't confuse to learn JavaScript. 𝗟𝗲𝗮𝗿𝗻 𝗧𝗵𝗶𝘀 𝗖𝗼𝗻𝗰𝗲𝗽𝘁 𝘁𝗼 𝗯𝗲 𝗽𝗿𝗼𝗳𝗶𝗰𝗶𝗲𝗻𝘁 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁. 𝗕𝗮𝘀𝗶𝗰𝘀 𝗼𝗳 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁: 1. JavaScript Syntax 2. Data Types 3. Variables (var, let, const) 4. Operators 5. Control Structures: 6. if-else, switch 7. Loops (for, while, do-while) 8. break and continue 9. try-catch block 10. Functions (declaration, expression, arrow) 11. Modules and Imports/Exports 𝗢𝗯𝗷𝗲𝗰𝘁-𝗢𝗿𝗶𝗲𝗻𝘁𝗲𝗱 𝗣𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁: 1. Objects and Prototypes 2. Classes and Constructors 3. Inheritance 4. Encapsulation 5. Polymorphism 6. Abstraction 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗖𝗼𝗻𝗰𝗲𝗽𝘁𝘀: 1. Closures and Lexical Scope 2. Hoisting 3. Event Loop and Call Stack 4. Asynchronous Programming (Promises, async/await) 5. Error Handling 6. Callback Functions 𝗗𝗮𝘁𝗮 𝗦𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁: 1. Arrays 2. Objects 3. Maps 4. Sets 𝗗𝗼𝗺 𝗔𝗻𝗱 𝗘𝘃𝗲𝗻𝘁 𝗛𝗮𝗻𝗱𝗹𝗶𝗻𝗴: 1. Accessing and Modifying DOM Elements 2. Event Listeners and Event Delegation 3. DOM Manipulation with JavaScript 4. Working with Forms and Inputs 𝗙𝗶𝗹𝗲 𝗔𝗻𝗱 𝗗𝗮𝘁𝗮 𝗛𝗮𝗻𝗱𝗹𝗶𝗻𝗴: 1. Working with JSON Data 2. Fetch API 3. AJAX Requests 4. LocalStorage and SessionStorage 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗔𝗿𝗿𝗮𝘆 𝗠𝗲𝘁𝗵𝗼𝗱𝘀: map(), filter(), reduce() find(), some(), every() sort(), forEach(), flatMap() 𝗘𝗦𝟲+ 𝗙𝗲𝗮𝘁𝘂𝗿𝗲𝘀: 1. Destructuring 2. Template Literals 3. Spread and Rest Operators 4. Default Parameters 5. Arrow Functions 6. Modules and Imports 𝗔𝘀𝘆𝗻𝗰 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁: 1. Promises 2. Async/Await 3. Fetch API 4. Error Handling in Async Code 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸𝘀 𝗮𝗻𝗱 𝗟𝗶𝗯𝗿𝗮𝗿𝗶𝗲𝘀: 1. React.js 2. Node.js 3. Express.js 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 𝗢𝗽𝘁𝗶𝗺𝗶𝘇𝗮𝘁𝗶𝗼𝗻 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁: 1. Debouncing and Throttling 2. Lazy Loading 3. Code Splitting 4. Caching and Memory Management 𝗜 𝗵𝗮𝘃𝗲 𝗰𝗿𝗲𝗮𝘁𝗲𝗱 𝗮 𝗖𝗼𝗺𝗽𝗹𝗲𝘁𝗲 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗣𝗿𝗲𝗽 𝗚𝘂𝗶𝗱𝗲 — covering JavaScript, React, Next.js, System Design, and more. 𝗚𝗲𝘁 𝘁𝗵𝗲 𝗚𝘂𝗶𝗱𝗲 𝗵𝗲𝗿𝗲- https://lnkd.in/gFmw8w6W If you've read so far, do LIKE and RESHARE the post👍
To view or add a comment, sign in
-
🌟 Call Stack vs Heap in JavaScript 🌟 Hey coder! Ever wondered how JavaScript remembers stuff while your code is running? Let’s break down the magic behind it — Call Stack and Heap. 1. Why do Call Stack & Heap even exist? 🤔 - Imagine your computer’s memory is like your workspace. You need one super tidy spot for quick notes (that’s the Call Stack), and a big, flexible storage box for bulky things like files and objects (that’s the Heap). - They help JavaScript keep track of what’s happening right now (calls, functions running) and remember bigger stuff like your objects and arrays without mixing everything up! 2. What exactly are they? 📦 - Call Stack: Think of it as a stack of plates 🍽️, where you can only add or remove the top plate. It keeps track of all the functions you’re running right now — last called, first finished! - Heap: This is a big, messy drawer 🗃️ where your objects, arrays, and functions live as long as needed. It’s unordered but roomy for all those complex, long-lasting items. 3. How do they work in JavaScript? 🎯 - When you run a function, JavaScript puts it on the Call Stack along with any small bits of info (like numbers or strings). - If your function creates objects or arrays, those live in the Heap, and the stack keeps a little pointer or reference to where they are. - Once a function finishes, it’s popped off the stack — that’s like clearing your desk of finished tasks so you can focus on new ones. 4. What about Garbage Collection (GC) in JavaScript? 🧹 - JavaScript has a built-in “clean-up crew” called Garbage Collector. - It watches for objects in the Heap that your code no longer points to from the Call Stack. - When it finds “orphaned” stuff nobody needs anymore, it sweeps it away to free up memory automatically — so you don’t have to worry about messy memory leaks! Quick Recap:- 🏃 Call Stack: Fast, orderly, handles running functions and simple data. 🏗️ Heap: Big, flexible, stores objects, arrays, and funky creatures 🐉. 🧹 Garbage Collector: Memory janitor who keeps your heap clean and efficient. 👩💻👨💻 Important Note 👩💻👨💻 - JavaScript’s Garbage Collector cleans up unused memory automatically, but to keep your app fast and efficient, you must also manage memory carefully. Avoid common pitfalls like forgotten event listeners, unnecessary globals, or circular references that lead to memory leaks. - Understanding how to use the stack and heap wisely helps you write smoother code — GC helps, but good coding habits are your best defence! Happy coding! Don’t worry if this feels tricky now — the more you code, the clearer it gets! 🎉 #JavaScriptMemory #CallStackVsHeap #BeginnerFriendly #ReactNative #MemoryManagement #CodeSmart #LearnJavaScript #WebDevelopment #CodingTips
To view or add a comment, sign in
-
🚀 Master JavaScript The Complete Foundation of Web Development JavaScript isn’t just a programming language it’s the backbone of modern web development 🌐 From crafting beautiful frontends with React, to building powerful backends with Node.js, everything starts with a solid grip on JavaScript fundamentals. I personally keep a JavaScript Cheat Sheet handy a complete reference from Basics → Advanced Concepts, all in one place ⚡ Here’s how I use it 👇 💡 Before starting a new project, I quickly revise core concepts section by section. 💡 It helps me strengthen my foundation variables, functions, async code, ES6+ features, and beyond. 💡 I update and recheck my understanding regularly to stay sharp and confident. 🧠 Complete JavaScript Roadmap From Basics to Advanced 🟩 1. JavaScript Fundamentals Variables (var, let, const) Data Types & Type Conversion Operators & Expressions Conditional Statements (if, switch) Loops (for, while, for...of, for...in) Functions & Function Expressions Arrow Functions Template Literals String, Number, and Math Methods 🟨 2. Intermediate Concepts Arrays & Array Methods (map, filter, reduce, etc.) Objects & Object Methods Destructuring & Spread/Rest Operators Scope & Hoisting Closures The “this” Keyword DOM Manipulation Events & Event Listeners JSON (Parse & Stringify) Modules (import, export) 🟧 3. Advanced JavaScript Prototypes & Inheritance Classes & OOP in JavaScript Error Handling (try...catch...finally) Promises & Async/Await Fetch API & HTTP Requests Event Loop & Call Stack Execution Context Higher-Order Functions Functional Programming Concepts Memory Management 🟥 4. Modern JavaScript (ES6+) Let & Const Template Strings Default, Rest & Spread Parameters Object Enhancements Modules Arrow Functions Destructuring Iterators & Generators Symbols & Sets/Maps 🟦 5. Browser & DOM DOM Tree Structure Query Selectors Creating & Modifying Elements Event Propagation (Bubbling & Capturing) LocalStorage & SessionStorage Cookies Browser APIs (Geolocation, Fetch, etc.) 🟪 6. Asynchronous JavaScript Callbacks Promises Async/Await Fetch API Error Handling in Async Code Microtasks vs Macrotasks ⚙️ 7. JavaScript in Practice ES Modules & Bundlers (Webpack, Vite, etc.) NPM Packages Node.js Basics (Modules, FS, HTTP) APIs (REST, JSON, Fetch) Debugging & Performance Optimization Testing (Jest, Mocha) 💡 8. JavaScript Patterns & Concepts Design Patterns (Module, Factory, Observer, Singleton, etc.) Clean Code & Best Practices Functional vs Object-Oriented JS Immutable Data Event-Driven Programming If you’re learning JavaScript 👉 Master these fundamentals once, and they’ll power you for a lifetime whether you go Frontend, Backend, or Full Stack. 🧩 Save this post 🔖 Revisit these topics whenever you revise your quick JS roadmap to track progress and growth. #JavaScript #WebDevelopment #Frontend #Backend #NodeJS #FullStack #Programming #CodingTips #LearningJourney #CheatSheet #DeveloperGrowth
To view or add a comment, sign in
-
-
What is JavaScript? 🔧 Hello LinkedIn community! In the world of web development, JavaScript has become a fundamental pillar. Today, I'm bringing you a clear summary of this programming language that powers interactivity on millions of sites. Based on a recent technical glossary, we explore its essence in a professional and accessible way. 🚀 History of JavaScript 📜 JavaScript, originally known as Mocha and later LiveScript, was created in 1995 by Brendan Eich while working at Netscape. Its launch coincided with the popularity of Java, which motivated the name change to capitalize on that fame, although they have no relation whatsoever. Today, it is standardized by Ecma International as ECMAScript and evolves with annual versions like ES6 or ES2023, adapting to the modern demands of development. Key Features ⚙️ - Interpreted and high-level language: It runs directly in the browser without needing prior compilation, which speeds up development. - Object-oriented and functional: It supports paradigms like prototyping and first-class functions, allowing flexible and reusable code. - Multiplatform: It works in browsers (client-side) and servers (with Node.js), making full-stack applications possible with a single language. - Asynchronous and non-blocking: Ideal for real-time operations, like dynamic updates without reloading pages. Current Uses in Development 🌐 - Web Interactivity: Creates dynamic elements like dropdown menus, form validations, and animations on sites like Google or Facebook. - Mobile and Desktop Applications: Frameworks like React Native or Electron enable cross-platform apps. - Backend and Data: With Node.js, it handles servers, APIs, and databases in high-performance environments. - Integration with AI and More: It's used in machine learning (TensorFlow.js) and blockchain, expanding its role beyond traditional web. JavaScript is not only essential for frontend programmers but also a versatile bridge for innovative solutions. If you're starting out or diving deeper into tech, mastering it opens doors to careers in software development. For more information, visit: https://enigmasecurity.cl #JavaScript #Programming #WebDevelopment #Technology #ECMAScript #NodeJS #SoftwareDevelopment Connect with me on LinkedIn to chat about tech trends: https://lnkd.in/eKynt-sy 📅 Fri, 24 Oct 2025 01:58:31 +0000 🔗Subscribe to the Membership: https://lnkd.in/eh_rNRyt
To view or add a comment, sign in
-
-
What is JavaScript? 🔧 Hello LinkedIn community! In the world of web development, JavaScript has become a fundamental pillar. Today, I'm bringing you a clear summary of this programming language that powers interactivity on millions of sites. Based on a recent technical glossary, we explore its essence in a professional and accessible way. 🚀 History of JavaScript 📜 JavaScript, originally known as Mocha and later LiveScript, was created in 1995 by Brendan Eich while working at Netscape. Its launch coincided with the popularity of Java, which motivated the name change to capitalize on that fame, although they have no relation whatsoever. Today, it is standardized by Ecma International as ECMAScript and evolves with annual versions like ES6 or ES2023, adapting to the modern demands of development. Key Features ⚙️ - Interpreted and high-level language: It runs directly in the browser without needing prior compilation, which speeds up development. - Object-oriented and functional: It supports paradigms like prototyping and first-class functions, allowing flexible and reusable code. - Multiplatform: It works in browsers (client-side) and servers (with Node.js), making full-stack applications possible with a single language. - Asynchronous and non-blocking: Ideal for real-time operations, like dynamic updates without reloading pages. Current Uses in Development 🌐 - Web Interactivity: Creates dynamic elements like dropdown menus, form validations, and animations on sites like Google or Facebook. - Mobile and Desktop Applications: Frameworks like React Native or Electron enable cross-platform apps. - Backend and Data: With Node.js, it handles servers, APIs, and databases in high-performance environments. - Integration with AI and More: It's used in machine learning (TensorFlow.js) and blockchain, expanding its role beyond traditional web. JavaScript is not only essential for frontend programmers but also a versatile bridge for innovative solutions. If you're starting out or diving deeper into tech, mastering it opens doors to careers in software development. For more information, visit: https://enigmasecurity.cl #JavaScript #Programming #WebDevelopment #Technology #ECMAScript #NodeJS #SoftwareDevelopment Connect with me on LinkedIn to chat about tech trends: https://lnkd.in/eVfce3YM 📅 Fri, 24 Oct 2025 01:58:31 +0000 🔗Subscribe to the Membership: https://lnkd.in/eh_rNRyt
To view or add a comment, sign in
-
-
Day 15/100 Day 6 of JavaScript Understanding Functions in JavaScript ? In JavaScript, functions are the building blocks of reusable code. They allow you to group statements that perform a specific task and execute them whenever needed — instead of writing the same code multiple times. What is a Function? A function is a block of code designed to perform a particular task. You can think of it as a machine — you give it some input (parameters), it processes it, and gives you an output (return value). Basic Function Syntax // Function Declaration function greet(name) { return `Hello, ${name}!`; } // Function Call console.log(greet("Appalanaidu")); Output: Hello, Appalanaidu! Here’s what’s happening: function greet(name) → defines a function named greet that takes one parameter, name. return → sends the output back to where the function was called. greet("Appalanaidu") → calls the function and passes "Appalanaidu" as the argument. Types of Functions in JavaScript Function Declaration function add(a, b) { return a + b; } console.log(add(5, 3)); // 8 Function Expression const multiply = function(x, y) { return x * y; }; console.log(multiply(4, 2)); // 8 Arrow Function (ES6) const divide = (a, b) => a / b; console.log(divide(10, 2)); // 5 Anonymous Function setTimeout(function() { console.log("This runs after 2 seconds"); }, 2000); Why Use Functions? Reusable — Write once, use multiple times Organized — Makes code clean and structured Testable — Easy to debug small blocks Scalable — Ideal for modular and maintainable applications Key Takeaway: Functions are the heart of JavaScript programming. They make your code efficient, readable, and easy to maintain — a must-know for every developer. #10000coders
To view or add a comment, sign in
-
💻 Hello all............... ➡️ Today concept is Scope and Closure in JavaScript. When learning JavaScript, two fundamental concepts that often confuse beginners are Scope and Closure. Mastering them helps you understand how variables work and how data can be securely handled inside functions. 🧩 Scope refers to the area in your code where a variable can be accessed. It defines the “visibility” of variables. JavaScript mainly has three types of scope: 1️⃣ Global Scope – A variable declared outside any function is global and can be accessed anywhere in the program. 2️⃣ Function Scope – Variables declared inside a function using var, let, or const are local to that function. 3️⃣ Block Scope – Variables declared inside { } with let or const exist only within that block (like inside loops or if statements). 4️⃣ lexical scope: calling / accessible the variable in the child function inside the parent function Understanding scope prevents naming conflicts and keeps code organized. 💡 Example: let a = 10; function test() { let b = 20; console.log(a + b); // ✅ Works } console.log(b); // ❌ Error – b is not in scope 🔒 Closure is a concept where an inner function “remembers” the variables and scope of its outer function, even after the outer function has finished executing. 💡 Example: function outer() { let count = 0; return function inner() { count++; console.log(count); }; } const counter = outer(); counter(); // 1 counter(); // 2 Here, inner() keeps access to count even after outer() has run. This is called a closure. It’s useful for data privacy, state management, and creating function factories. ⚙️ In short: Scope decides where variables live. Closure allows functions to remember their environment. Harish M Manivardhan Jakka 10000 Coders #JavaScript #WebDevelopment #Learning #Closures #Scopes #Programming #FullStackDevelopment #WebDevelopment #FrontendDevelopment #FullStackDeveloper #HTML #CSS #JavaScript #ReactJS #Programming #CodeNewbie #WebDesign #UIUX #ResponsiveDesign #CleanCode #CodingLife #SoftwareDevelopment #PortfolioProject #PersonalProject #SideProject #LearningByDoing #CodeLearning #BuildInPublic #ProjectShowcase #TechProjects #WebDevPortfolio #CareerGrowth #TechCommunity #Developers #CodingCommunity #WomenInTech #TechTalent #JobSeekers #FutureOfWork #Python #PythonDeveloper #PythonProgramming #PythonTips #PythonCode #LearnPython #Coding #Programming #Developer #FullStackDevelopment #WebDevelopment #BackendDevelopment #SoftwareDevelopment #APIDevelopment #Django #Flask #FastAPI #MachineLearning #DataScience #ArtificialIntelligence #DeepLearning #Tech #Innovation #CloudComputing #Automation #CodeNewbie #100DaysOfCode #DevCommunity #CareerInTech #TechCareers #CodingLife #DeveloperCommunity #ProgrammingLife #OpenSource #TechTrends #SoftwareEngineer #CodeDaily #StartupLife #UIDesign #FrontendDevelopment #CSS #CSSGradients #WebDesign #DesignInspiration #CreativeCoding #DigitalDesign #TechSkills
To view or add a comment, sign in
-
-
💻 Day 26 - Diving into JavaScript Basics! 🚀 Today’s session in Cohort 2.0 was all about getting comfortable with one of the most powerful and essential programming languages for web development - JavaScript! 🌐✨ Here’s what I explored and understood today 👇 🔹 What is JavaScript & Why it’s Used: JavaScript is the brain of modern websites - it makes web pages interactive, dynamic, and intelligent. From animations to real-time updates, JS brings life to the static structure built using HTML & CSS. 🔹 Variables - var, let & const: These are used to store data. var : Function-scoped and can be re-declared. let : Block-scoped, cannot be re-declared within the same scope. const : Constant, cannot be changed once assigned. Understanding their scope and behavior is key to avoiding common JS pitfalls! ⚡ 🔹 Strings & Numbers: When a number is combined with a string, JavaScript converts it into a string (a process called type coercion). Example: console.log(10 + "5"); // Output: "105" To perform calculations inside strings, we use template literals - enclosed in backticks (`): let total = 10; console.log(`Total is ${total + 5}`); // Output: Total is 15 🔹 Useful String Methods: Some super handy methods to manipulate text data - slice(start, end) : Extracts part of a string replace() : Replaces first match replaceAll() : Replaces all occurrences includes() : Checks if a string contains a given value split() : Converts a string into an array 🔹 Console Methods: Used to display messages and debug your code easily 👇 console.log() : Print outputs console.warn() : Show warnings console.error() : Show errors console.info() : Show informational messages 🔹 Prompt & Alerts: Used for interaction with users in the browser - alert() : Shows a popup message prompt() : Takes user input Lastly, I learned how to declare and initialize variables properly - the foundation of working with any programming language. 🎯 Key Takeaway: JavaScript is not just about syntax - it’s about thinking dynamically and understanding how browsers interpret your logic. Excited for the upcoming topics as we go deeper into JS functions, objects, arrays, and DOM manipulation! 💪🔥 #Day26 #Cohort2 #JavaScript #WebDevelopment #LearningJourney #FrontendDevelopment #CodingInPublic #JavaScriptBasics #CodeNewbie #100DaysOfCode Sheryians Coding School Community Sheryians Coding School Community
To view or add a comment, sign in
-
🧩 Understanding “Palindrome Number” in JavaScript — Beginner Friendly 💡 When I first learned about palindrome numbers (like 121 or 1223221), I got confused by one simple question: 👉 “Why do we need another variable like original to store the number?” Let’s break it down 👇 🔍1️⃣What happens inside the loop? This part confuses many learners at first. When you use the same variable inside the loop (like x or n), you keep changing it in every iteration: let x = 121; let rev = 0; while (x > 0) { let rem = x % 10; rev = 10 * rev + rem; x = Math.floor(x / 10); } console.log("x =", x); // 👉 0 console.log("rev =", rev); // 👉 121 🧠 Inside the loop, you are dividing x each time → x = 0 at the end. So when the loop ends, you lose the original number. That’s why we store it first 👇 let original = x; Then at the end: return original === rev; ✅ This way, you still have the original value to compare. 🧩 2️⃣ When you don’t need original If you pass the number as a parameter, JavaScript creates a copy of it — so the outer value stays safe even if the inner one changes. let n = 121; function palindrome(num) { let rev = 0; while (num > 0) { let rem = num % 10; rev = 10 * rev + rem; num = Math.floor(num / 10); } return rev; } let result = palindrome(n); console.log("n =", n); // 👉 still 121 console.log("result =", result); // 👉 121 ✅ Here you don’t need original because: The function gets a copy of n (numbers are passed by value). Inside the function, only that copy (num) becomes 0. The outer n never changes — it still holds the original number. 🧠 So you can safely compare like: if (n === result) console.log("Palindrome"); 🔍 3️⃣ Why x is 0 even outside the loop That’s a very smart question 👏 — and it shows real understanding of JavaScript. Because in JavaScript, variables declared with let inside the same function share the same function scope — not separate scopes for loops. That means: You used the same variable x inside and outside the loop. Each time in the loop you did x = Math.floor(x / 10). When the loop finishes, x keeps its last modified value → 0. 💡 In short: while doesn’t create a new scope — so x keeps changing even outside the loop. ✅ If you want to keep the original safe → copy it before modifying: let original = x; ✨I shared this because I know how small confusions like these can stop learning flow. Small things like these make a big difference when learning JavaScript logic. If this helped you understand the “original” confusion, drop a 💬 or ❤️ to help other learners too! #JavaScript #CodingJourney #FrontendDevelopment #DeveloperTips #LearnByDoing
To view or add a comment, sign in
-
In a Javascript L1 & L2 round the following questions can be asked from interviewer. Learn all ques for free on interviewdepth.com 1. What is the difference between 'Pass by Value' and 'Pass by Reference'? 2. What is the difference between map and filter ? 3. What is the difference between map() and forEach() 4. What is the difference between Pure and Impure functions? 5. What is the difference between for-in and for-of ? 6. What are the differences between call(), apply() and bind() ? 7. List out some key features of ES6 ? 8. What’s the spread operator in javascript ? 9. What is rest operator in javascript ? 10. What are DRY, KISS, YAGNI, SOLID Principles ? 11. What is temporal dead zone ? 12. Different ways to create object in javascript ? 13. Whats the difference between Object.keys,values and entries 14. Whats the difference between Object.freeze() vs Object.seal() 15. What is a polyfill in javascript ? 16. What is generator function in javascript ? 17. What is prototype in javascript ? 18. What is IIFE ? 19. What is CORS ? 20. What are the different datatypes in javascript ? 21. What are the difference between typescript and javascript ? 22. What is authentication vs authorization ? 23. Difference between null and undefined ? 24. What is the output of 3+2+”7” ? 25. Slice vs Splice in javascript ? 26. What is destructuring ? 27. What is setTimeOut in javascript ? 28. What is setInterval in javascript ? 29. What are Promises in javascript ? 30. What is a callstack in javascript ? 31. What is a closure ? 32. What are callbacks in javascript ? 33. What are Higher Order Functions in javascript ? 34. What is the difference between == and === in javascript ? 35. Is javascript a dynamically typed language or a statically typed language 36. What is the difference between Indexeddb and sessionstorage ? 37. What are Interceptors ? 38. What is Hoisting ? 39. What are the differences let, var and const ? 41. Differences between Promise.all, allSettled, any, race ? 42. What are limitations of arrow functions? 43. What is difference between find vs findIndex ? 44. What is tree shaking in javascrip 45. What is the main difference between Local Storage and Session storage 46. What is eval() 47. What is the difference between Shallow copy and deep copy 48. What are the difference between undeclared and undefined variables 49. What is event bubbling 50. What is event capturing 51. What are cookies 52. typeOf operator 53. What is this in javascript and How it behaves in various scenarios 54. How do you optimize the performance of application 55. What is meant by debouncing and throttling #javascriptdeveloper #reactjs #reactnative #vuejsdeveloper #angular #angulardeveloper
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
Great start! Very clear explanation of JavaScript fundamentals 👍