📘 Day 63: JavaScript String Methods 🔹 String methods help manipulate and analyze text in JavaScript. They make working with user input and text data much easier. 💡 Common String Methods: 🔸 length • Finds total characters in a string • Spaces are also counted 🔸 replace() • Replaces the first matched word with another word 🔸 replaceAll() • Replaces all repeated matches in the string 🔸 split() • Splits a string into an array • Useful for separating words or values 🔸 indexOf() • Returns the position (index) of a character or word 🔸 slice() • Extracts part of a string using a range 🔸 trim() • Removes extra spaces from start and end • Does not affect spaces between words 💡 Checking Methods (Return True/False): 🔸 startsWith() • Checks if string begins with a specific value 🔸 endsWith() • Checks if string ends with a specific value 🔸 includes() • Checks if a word exists inside a string 💡 Case Conversion: 🔸 toUpperCase() • Converts all letters to uppercase 🔸 toLowerCase() • Converts all letters to lowercase 💡 Search & Combine: 🔸 search() • Finds position of a word • Returns -1 if not found 🔸 concat() • Joins multiple strings together ✨ These methods are essential for form validation, search features, and text formatting in real-world web development. #JavaScript #Day63 #WebDevelopment #FrontendDevelopment #CodingJourney #JSBasics #StringMethods #LearnJavaScript #TechSkills
JavaScript String Methods: Essential for Web Development
More Relevant Posts
-
Day 46 of #180daysofcode 🚀 Part 1 Today I revised JavaScript Fundamentals – the real brain behind web applications 🧠 We often say: HTML → Structure CSS → Design JavaScript → Brain But what exactly does that mean? ❓ What is JavaScript? Makes web pages interactive Runs inside the browser Controls logic and behavior Without JavaScript, websites are just static pages. 📦 Variables in JavaScript Variables store data in memory. There are 3 ways to declare variables: 🔹 let Value can change Block scoped Most commonly used 🔹 const Cannot be reassigned Used for fixed values 🔹 var (avoid in modern JS) Function scoped Old style Example: Javascript Copy code let age = 25; const name = "Deepak"; 🧾 JavaScript Data Types JavaScript is dynamically typed. 🔢 Number Javascript Copy code let score = 90; 📝 String Javascript Copy code let city = "Delhi"; ✅ Boolean Javascript Copy code let isLoggedIn = true; 📦 Undefined Javascript Copy code let x; 🚫 Null Javascript Copy code let data = null; 🧠 Object Javascript Copy code let user = { name: "Amit", age: 30 }; 📚 Array Javascript Copy code let skills = ["HTML", "CSS", "JS"]; Mastering fundamentals makes advanced concepts easier later. Strong basics = Strong developer foundation 💪 #JavaScript #WebDevelopment #FrontendDevelopment #CodingJourney #100DaysOfCode #LearnToCode #Developers
To view or add a comment, sign in
-
Linking JS file Sounds small… but it’s VERY important. 🔥 Without linking JS properly, your website is just a static page. 💡 What is a JS File? A JavaScript file (script.js) contains code that makes your website: ✅ Interactive ✅ Dynamic ✅ Responsive to user actions For example: - Button click events - Form validation - Show/Hide content - API calls 🛠 How to Link JavaScript File? There are 2 common ways: ✅ 1️⃣ Inside <head> <head> <script src="script.js"></script> </head> Problem ❌ JS loads before HTML → can cause errors. ✅ 2️⃣ Before Closing </body> <body> <script src="script.js"></script> </body> Why this is better? ✔ HTML loads first ✔ Then JavaScript runs ✔ Faster page experience 🎯 What I Understood Today Linking JS file is simple but powerful. One small line connects your entire logic to the UI. #WebDevelopment #JavaScript #Programming #Coding #SoftwareDevelopment #Tech
To view or add a comment, sign in
-
-
This JavaScript array question surprises many developers 👀 🧩 JavaScript Output-Based Question (Array length + delete) ❓ What will be the output? 👉 Comment your answer below (Don’t run the code ❌) Correct Output : 11 Why this output comes? (Step-by-Step) 1️⃣ Initial array ['a','b','c','d','e'] Length = 5 2️⃣ Assigning value at index 10 array[10] = 'f'; • JavaScript creates empty slots between index 5–9 • Array becomes sparse • Length becomes highest index + 1 ➡️ Length = 11 3️⃣ Deleting the element delete array[10]; • delete removes the value • ❌ It does NOT reindex the array • ❌ It does NOT reduce length So the slot becomes empty, but length stays the same. ➡️ Final length = 11 🔑 Key Takeaways : ✔️ Array length depends on highest index ✔️ delete removes value, not index ✔️ delete does NOT change array length ✔️ Sparse arrays are common sources of bugs delete is usually a bad choice for arrays. #JavaScript #Arrays #InterviewQuestions #FrontendDeveloper #MERNStack #WebDevelopment
To view or add a comment, sign in
-
-
JavaScript has primitive and reference types. 🧩 ❓ Why do objects behave differently during assignment? In JavaScript, values are stored in two different ways: by value and by reference. 🔹 Primitive types (stored by value) Primitives like number, string, boolean, null, undefined, symbol, and bigint store the actual value. let a = 10; let b = a; b = 20; console.log(a); // 10 ✅ Here, b gets a copy of a. Changing b does not affect a. 🔹 Reference types (stored by reference) Objects, arrays, and functions store a reference (address in memory), not the actual value. let obj1 = { name: "Isnaan" }; let obj2 = obj1; obj2.name = "Ashraf"; console.log(obj1.name); // "Ashraf" 😮 Both variables point to the same object in memory. Changing one affects the other. ⚠️ Why this matters This behavior can cause unexpected bugs if you think you’re copying an object but actually sharing it. 💡 Best practice To avoid side effects, create a copy using: let newObj = { ...obj1 }; Takeaway: Primitives are copied. Objects are shared. Understanding this saves hours of debugging. #learnwithisnaan #mernstackdeveloper #fullstackdeveloper #javascript #freelancer
To view or add a comment, sign in
-
-
What Actually Is JavaScript? And How Does It Run in the Browser? JavaScript is a high-level, interpreted programming language used to make web pages interactive. HTML → Structure CSS → Styling JavaScript → Behavior Without JavaScript, websites would be static. What JavaScript Really Is JavaScript is: • Single-threaded • Event-driven • Dynamically typed • Prototype-based It allows you to: - Handle user clicks - Update the DOM - Fetch data from APIs - Build full web applications How JavaScript Runs in the Browser JavaScript runs inside a JavaScript Engine built into the browser. Examples: Chrome → V8 Engine Firefox → SpiderMonkey Here’s what happens when a browser loads a website: 1. Browser loads HTML 2. It builds the DOM (Document Object Model) 3. When it finds <script> 4. The JavaScript engine parses and executes the code Behind the Scenes Inside the browser: • Call Stack → Executes functions • Web APIs → Handle async tasks (setTimeout, fetch, DOM events) • Callback Queue → Stores completed async tasks • Event Loop → Moves tasks to call stack when ready That’s how JavaScript handles asynchronous behavior even though it’s single-threaded. In Simple Terms JavaScript runs in the browser using: JavaScript Engine + Call Stack + Web APIs + Event Loop And that’s what makes websites interactive. #JavaScript #WebDevelopment #Frontend #Programming #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 15: The this Keyword in JavaScript this is one of the most misunderstood concepts in JavaScript 🤯 Its value depends on HOW a function is called, not where it is written. 🔹 1️⃣ Global Scope console.log(this); 👉 In browser → window 👉 In Node → {} (module.exports) 🔹 2️⃣ Inside a Regular Function function show() { console.log(this); } show(); 👉 In non-strict mode → window 👉 In strict mode → undefined 🔹 3️⃣ Inside an Object Method const user = { name: "Shiv", greet: function() { console.log(this.name); } }; user.greet(); 👉 this refers to the object → user 🔹 4️⃣ Arrow Function const user = { name: "Shiv", greet: () => { console.log(this); } }; user.greet(); 👉 Arrow functions do NOT have their own this 👉 They inherit from their lexical scope 🔥 Key Rule this depends on: ✔️ How the function is called ✔️ Whether it’s arrow or regular ✔️ Strict mode 🧠 Why Important? ✔️ Core interview topic ✔️ Important in React ✔️ Needed for call, apply, bind #JavaScript #thisKeyword #Frontend #Webdevelopment #learnInPublic
To view or add a comment, sign in
-
Debounce vs Throttle in JavaScript – Performance Optimization Handling frequent events like scroll, resize, and search input can easily impact application performance if not optimized properly. Two powerful techniques used in modern JavaScript applications are Debounce and Throttle. 🔹 Debounce Debounce delays the execution of a function until the user stops triggering the event for a specific time. ✔ Best used for search inputs, form validation, and auto-save features ✔ Prevents unnecessary API calls Example: When a user types in a search bar, the API request is triggered only after the user stops typing. 🔹 Throttle Throttle ensures a function executes at a fixed interval, even if the event triggers multiple times. ✔ Best used for scroll events, resize events, and mouse movement ✔ Limits how often a function runs Example: While scrolling a page, the function executes every few milliseconds instead of hundreds of times per second. 💡 Simple Rule to Remember Debounce → Wait until action stops Throttle → Run at regular intervals These techniques help developers build high-performance and responsive web applications. #JavaScript #FrontendDevelopment #PerformanceOptimization #WebDevelopment #Angular #CodingTips 🚀
To view or add a comment, sign in
-
-
JAVASCRIPT NOTES — PART 1 (Foundations) After structure (HTML) and styling (CSS), JavaScript is where logic begins. This post covers the fundamentals that everything else depends on: • Variables (let, const, scope) • Data types • Operators & type coercion • Conditionals & loops • Functions & hoisting Most confusion in JavaScript doesn’t come from complexity — it comes from unclear basics. Before frameworks, before React, understanding these concepts clearly makes everything easier. 📌 Save this if you’re building JavaScript properly. #JavaScript #WebDevelopment #FrontendDeveloper #LearningInPublic #InterviewPrep #StudentDeveloper #Consistency
To view or add a comment, sign in
-
𝗛𝗼𝘄 𝗝𝗮 v𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗪𝗼𝗿𝗸𝘀 𝗢𝗻 𝗕𝗿𝗼𝘄𝘀𝗲𝗿 You want to know how JavaScript works on a browser. Let's break it down. JavaScript is a programming language that makes web pages interactive. It was created to run inside browsers, but now it also runs on servers using environments like Node.js. A web page is made of: - HTML: structure - CSS: styling - JavaScript: behavior When you visit a web page, your browser loads HTML, creates a DOM tree, and downloads CSS to create a CSSOM. These combine to form a Render Tree, which is displayed on the screen. The browser has a rendering engine and a JavaScript engine, like Google's V8. The V8 engine executes JavaScript code, but it does not change the DOM or UI. Instead, it uses browser APIs to do that. Browser APIs include: - document - getElementById - querySelector - createElement - setTimeout - fetch - WebSocket - localStorage - sessionStorage - geolocation - history - navigator The V8 engine's code is written in C++. To understand the event loop, you need to know how JavaScript code executes. JavaScript is a single-threaded language, so every instruction is executed line by line. The JavaScript engine creates a global execution context, which is divided into two sections: - variable environment - execution context When a promise comes, it goes into the microtask queue, and when a timeout is called, it goes into the callback queue. The event loop resolves the microtask queue first, then the callback queue. When you open a website, your browser downloads HTML, creates a DOM tree, and downloads CSS to create a CSSOM. If JavaScript exists, it is sent to the V8 engine, which executes it. If JavaScript modifies the DOM, the browser updates the DOM, and the screen updates. Source: https://lnkd.in/gJirTwcw
To view or add a comment, sign in
-
The Magic of "this" keyword, call(), apply(), and bind() in JavaScript Here is my latest in-depth blog on 'this' in JS and call, apply, and bind
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