🚀 Day 41 of #100DaysOfWebDevelopment Challenge Today, I explored some of the most commonly used JavaScript String Methods — tools that help manipulate and format text efficiently. 🔹 trim() The trim() method removes any unnecessary whitespace from the beginning and end of a string. It’s extremely useful when handling user input or text data that may contain extra spaces. 🔹 toUpperCase() & toLowerCase() These methods convert text to uppercase or lowercase, helping in formatting or case-insensitive comparisons. For example: "hello".toUpperCase() → "HELLO" 🔹 String Methods with Arguments Some string methods accept arguments — values you pass inside parentheses to control their behavior. For instance, indexOf("a") returns the position of the first occurrence of the letter "a" in a string. 🔹 indexOf() This method helps find the index (position) of a specific character or substring. It returns -1 if the value isn’t found — making it handy for search operations in text. 🔹 Method Chaining I learned that multiple methods can be combined in a single line — known as method chaining. 🔹 slice() The slice() method extracts a part of a string and returns it as a new string without modifying the original. 🔹 replace() This method replaces a specified value with another value in a string. It’s very useful for text transformation or cleaning data. 🔹 repeat() Finally, I explored the repeat() method, which repeats a string a specified number of times — great for generating patterns or visual output. #100DaysOfCode #WebDevelopment #JavaScript #FrontendDevelopment #LearningInPublic #CodingJourney
Exploring JavaScript String Methods in #100DaysOfWebDevelopment
More Relevant Posts
-
✨I am excited to share about stages of errors in javascript. while learning JavaScript,i realized that errors are not just mistakes-they are an important part of how code works and how we debug efficiently. Types of errors in javascript: ➡️Syntax error:This happens before the code runs,when javascript checks the syntax. ex:console.log("Hello" //syntaxerror:missing paranthesis ➡️ Reference error:This error occurs while the program is running -after syntax checking ex: console.log(x) //reference error:x is not defined. ➡️Type error:A type error occurs when an operation or function is applied to a value of the wrong type. ex:let person console.log(person.name)//Type error: cannot read properties of undefined. ➡️A URI(Uniform Resource Identifier) occurs when a malformed uri is passed to a URI handling function. ex:decodeURI('%');//uri error:uri malformed ➡️Range error:A range error occurs when you give a function a value that's outside it's valid range,even though the type is correct. ex:let arr=new array(-2)//range error: Invalid array length #Javascript #webdevelopment #coding #Learningjourney #Debugging #10000coders #sudheervelpula
To view or add a comment, sign in
-
-
Most beginners write messy if-else logic — pros don’t. In JavaScript, mastering conditional statements means writing logic that’s not just functional, but readable and scalable. This post breaks down every major pattern: 1. if / else / else if 2. switch 3. ternary operator 4. logical & short-circuit operators 5. optional chaining and nullish coalescing real-world validation and role-based logic Want to level up your JavaScript readability game? Share the worst if-else chain you’ve ever written. https://lnkd.in/dVuD2ZWq #JavaScript #WebDevelopment #CodingTips #FrontendDev #ProgrammingBasics #LearnToCode #Nextjs #MERNStack
To view or add a comment, sign in
-
🔥 JavaScript: When “prototype” is NOT an object 👀 We all learn early — > “Every function in JavaScript has a prototype property that is an object.” But JavaScript loves exceptions 😏 Here are some surprising cases where prototype is not an object 👇 RegExp.prototype // → /(?:)/ Array.prototype // → [] Function.prototype // → ƒ () {} Number.prototype // → Number {} String.prototype // → String {} Boolean.prototype // → Boolean {} Symbol.prototype // → Symbol {} BigInt.prototype // → BigInt {} 💡 Notice something? Some of these are functions, arrays, or even regular expressions! That’s because their prototypes are actual instances of their types, not plain objects — so that all instances inherit their core methods directly. For example: Array.prototype.push === [].push // true ✅ RegExp.prototype.test === /abc/.test // true ✅ So next time you assume prototype is always {}, remember — JS is full of living examples 😉 --- 💬 Have you ever found a weird prototype behavior while debugging? Drop it in the comments — let’s break more JS myths together! ⚙️ #JavaScript #WebDevelopment #LearningEveryday #Frontend
To view or add a comment, sign in
-
Exploring Different Methods to Calculate the Sum of Two Numbers in JavaScript When it comes to adding two numbers in JavaScript, there are various approaches to achieve the result. One common method involves defining variables for the numbers, such as: var a = 2; var b = 3; function sum(){ return a + b; } sum(); Alternatively, you can directly pass the numbers into a function for instant calculation: function sum(a, b){ return a + b; } sum(2, 3); For real-time feedback while coding, utilizing "console.log" can display the result promptly: function sum(a, b){ console.log(a + b); } sum(2, 3); Remember, JavaScript's case sensitivity emphasizes the importance of accurately typing uppercase and lowercase letters in your code. Stay precise for seamless execution! #JavaScriptTips #CodingMethods #JavaScript
To view or add a comment, sign in
-
🚀 Mastering JavaScript String Methods Understanding String Methods is one of the fastest ways to level up your JavaScript skills. From searching, slicing, trimming, transforming text — string functions make data handling super easy and powerful. This chart gives a quick snapshot of commonly used methods like: ✔️ charAt() ✔️ concat() ✔️ startsWith() / endsWith() ✔️ includes() ✔️ indexOf() ✔️ slice() / substring() ✔️ match() ✔️ replace() ✔️ repeat() ✔️ trim() ✔️ toLowerCase() / toUpperCase() … and more! 📌 If you're learning JavaScript or improving your frontend skills, mastering these methods is a must. 💡Pro tip: Don't just memorize these - practice them in small projects to build muscle memory. #JavaScript #WebDevelopment #Coding #Frontend #Learning #StringMethods #MERNStack #JavaScriptTips
To view or add a comment, sign in
-
-
#1: JavaScript Variables - From Basics to Best Practices 🚀 Just stumbled upon a JavaScript behavior that might surprise many beginners - and even some experienced developers! Let me break it down: // The usual suspects const apiKey = "abc123"; let userName = "sandeepsharma"; var userRole = "admin"; // The sneaky one that causes trouble userLocation = "Berlin"; // Wait, no declaration?! Here's what's happening behind the scenes: When you assign a value without const, let, or var, JavaScript quietly creates a global variable: // In browser environments: window.userLocation = "Berlin"; console.log(userLocation); // "Berlin" - it works! Why this should scare you: 🌐 Pollutes the global namespace 🔍 Makes debugging a nightmare 💥 Can overwrite existing variables 🚨 Throws ReferenceError in strict mode The Professional Fix: "use strict"; // Your new best friend const apiKey = "abc123"; // Constant values let userName = "sandeepsharma"; // Variables that change var userRole = "admin"; // Legacy - avoid in new code let userStatus; // Properly declared undefined My Golden Rules for Variables: 1. Start with const - use it by default 2. Upgrade to let only when reassignment is needed 3. Retire var - it's time to move on 4. Never use undeclared variables - strict mode prevents this 5. Always initialize variables - even if with undefined Pro Debugging Tip: // Instead of multiple console.log statements: console.table({apiKey, userName, userRole, userLocation, userStatus}); Notice Line: Explicit declarations make your code more predictable, maintainable, and professional. That accidental global variable might work today but could cause hours of debugging tomorrow! What's your favorite JavaScript variable tip? Share in the comments! 👇 #JavaScript #WebDevelopment #ProgrammingTips #Coding #SoftwareEngineering #Tech #CareerGrowth
To view or add a comment, sign in
-
💻✨ JavaScript String Methods – Practice Tasks Completed! I recently completed a series of practical exercises to strengthen my understanding of JavaScript string manipulation. These tasks covered common string methods, from basic character access to advanced formatting and substring operations. 🧩 Tasks & Key Learnings: Character Finder: Used charAt(), charCodeAt(), and .at() to find characters and ASCII values. Combine & Search: Combined strings with concat(). Searched using includes(), indexOf(), and lastIndexOf(). Text Formatting: Trimmed spaces (trim(), trimStart(), trimEnd()) and changed case (toUpperCase(), toLowerCase()). Extract Substrings: Extracted portions of strings using slice() and substring(). Padding Magic: Added characters to start or end of a string using padStart() and padEnd(). Replace & Compare: Replaced text using replace() & replaceAll() and compared strings using localeCompare(). Mixed Operations (Mini Project): Built a function analyzeString() to return a comprehensive analysis of a string: length, first & last characters, uppercase/lowercase, inclusion of a word, slicing, and trimmed version. 🎯 Outcome: By completing these tasks, I enhanced my ability to: Access and manipulate string data effectively Apply multiple string methods in combination Solve real-world problems involving text processing 💡 These exercises are a great way to solidify fundamental JavaScript skills and prepare for more advanced projects and challenges! #JavaScript #WebDevelopment #FrontendDevelopment #Coding #LearningJourney #Programming #StringMethods #DeveloperSkills #TechSkills #Coding #JS #SpandanaChowdary #MeghanaM #10000Coders
To view or add a comment, sign in
-
Understanding How JavaScript Manages Memory: Stack, Heap & Garbage Collection As developers, we often use JavaScript every day, but few of us pause to think about how it really manages memory behind the scenes. 🧠 Memory Types: - Stack Memory: Stores primitive data types (like numbers, strings, booleans). These are copied by value — meaning every variable gets its own copy. - Heap Memory: Stores non-primitive data types (like objects, arrays, functions). These are copied by reference — multiple variables can point to the same memory location. 🧹Garbage Collection: JavaScript automatically cleans up unused memory through a process called Garbage Collection, based on the concept of reachability. How It Works Reachability: JS keeps objects in memory if they are reachable (accessible from roots. Unreachable Objects: If an object is no longer referenced, it becomes eligible for garbage collection. Mark-and-Sweep Algorithm: Mark: Identify all reachable objects. Sweep: Delete objects not marked as reachable. Does understanding memory management change the way you write JavaScript? #JavaScript #WebDevelopment #Frontend #MemoryManagement #CodingTips #Developers
To view or add a comment, sign in
-
-
🌀 𝗠𝗮𝘀𝘁𝗲𝗿𝗶𝗻𝗴 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗣𝗿𝗼𝘅𝗶𝗲𝘀 — 𝗜𝗻𝘁𝗲𝗿𝗰𝗲𝗽𝘁, 𝗖𝗼𝗻𝘁𝗿𝗼𝗹 & 𝗣𝗼𝘄𝗲𝗿 𝗨𝗽 𝗬𝗼𝘂𝗿 𝗢𝗯𝗷𝗲𝗰𝘁𝘀 Wrappers, traps, handlers — the native Proxy object in JavaScript gives you 𝗺𝗲𝘁𝗮-𝗰𝗼𝗻𝘁𝗿𝗼𝗹 over how your objects behave. Want to intercept property access, validate assignments, or log operations? Proxies unlock that power. In this post I break down: ✅ What Proxy objects really do (the target + handler + traps model) ✅ How traps like `get`, `set`, `apply`, `construct` let you intercept reads, writes, function calls and constructor calls ✅ Real-world use cases: validation, access control, logging, lazy initialization, smart defaults 👉 Read here: https://lnkd.in/d2z-7z6w Stay curious. Code smarter. 🧠 #JavaScript #WebDevelopment #Proxies #Metaprogramming #CodingTips
To view or add a comment, sign in
-
𝗨𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 𝗟𝗲𝘅𝗶𝗰𝗮𝗹 𝗦𝗰𝗼𝗽𝗶𝗻𝗴 𝗮𝗻𝗱 𝗖𝗹𝗼𝘀𝘂𝗿𝗲𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 Every JavaScript developer must master two powerful concepts: 𝗟𝗲𝘅𝗶𝗰𝗮𝗹 𝗦𝗰𝗼𝗽𝗶𝗻𝗴 and 𝗖𝗹𝗼𝘀𝘂𝗿𝗲𝘀 — because they form the foundation of how functions truly work under the hood. ♟️𝗟𝗲𝘅𝗶𝗰𝗮𝗹 𝗦𝗰𝗼𝗽𝗶𝗻𝗴: It determines where variables can be accessed in your code. In JavaScript, a function can access variables defined in its own scope and in the scope where it was declared, not where it’s called. ♟️𝗖𝗹𝗼𝘀𝘂𝗿𝗲𝘀: When a function “remembers” the variables from its outer scope even after that outer function has finished executing — that’s a closure in action. They allow functions to have “private” data and maintain state. As you can see in the picture below, example code shows that 𝚒𝚗𝚗𝚎𝚛() keeps access to count even after 𝚘𝚞𝚝𝚎𝚛() has returned — that’s the magic of 𝗰𝗹𝗼𝘀𝘂𝗿𝗲𝘀! ♟️Pro Tip: 𝗖𝗹𝗼𝘀𝘂𝗿𝗲𝘀 are the secret behind many JS patterns like 𝗱𝗮𝘁𝗮 𝗽𝗿𝗶𝘃𝗮𝗰𝘆, 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻 𝗳𝗮𝗰𝘁𝗼𝗿𝗶𝗲𝘀, and 𝗲𝘃𝗲𝗻𝘁 𝗵𝗮𝗻𝗱𝗹𝗲𝗿𝘀. #JavaScript #WebDevelopment #Coding #Closures #LexicalScope #FrontendDevelopment #JSConcepts #WebDevCommunity #LearnToCode #CodeNewbie #ProgrammingTips #100DaysOfCode #DeveloperJourney
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