𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝗮𝗿𝗲 𝗴𝗿𝗲𝗮𝘁, 𝗯𝘂𝘁 𝗧𝘆𝗽𝗲𝗦𝗰𝗿𝗶𝗽𝘁 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀 𝗮𝗿𝗲 𝗮 𝗴𝗮𝗺𝗲-𝗰𝗵𝗮𝗻𝗴𝗲𝗿. 🚀 One of the biggest headaches in plain JS is passing the wrong type of argument to a function and only finding out at runtime. TypeScript solves this by letting us define strict contracts for our code. By simply adding types to your parameters and explicitly stating your return type, you get two massive benefits: 1️⃣ Instant IDE autocomplete 2️⃣ Catching bugs before you even hit save // The TypeScript Way 🛡️ function calculateDiscount(price: number, discount: number = 10): number { return price - (price * (discount / 100)); } // Hovering over this, your IDE knows exactly what to expect! const finalPrice = calculateDiscount(500); Once you start strictly typing your functions, you never want to go back. I’ve just uploaded a new video diving deep into everything you need to know about functions in TypeScript. It’s the latest episode in my ongoing TypeScript series on YouTube, where we're breaking down these concepts step by step. 𝗖𝗵𝗲𝗰𝗸 𝗼𝘂𝘁 𝘁𝗵𝗲 𝗳𝘂𝗹𝗹 𝘁𝘂𝘁𝗼𝗿𝗶𝗮𝗹 𝗵𝗲𝗿𝗲: https://lnkd.in/gyexUVgs What’s your favourite TS feature that saves you the most time during debugging? Let me know in the comments! #TypeScript #JavaScript #WebDevelopment #SoftwareEngineering #CodingTutorial #DeveloperCommunity
TypeScript solves runtime errors with strict function contracts
More Relevant Posts
-
🔥 Day 3 of #100DaysOfCode Today I went deep into Node.js Runtime Fundamentals — straight from the official docs. No building. Just understanding. Here’s what clicked: 📌 Node.js is a JavaScript runtime, not a framework. It runs JS outside the browser using the V8 engine. 📌 It’s event-driven and non-blocking — meaning it doesn’t wait for tasks like file reads or database calls before moving on. 📌 The event loop is the core. It lets Node handle many operations efficiently on a single thread. 📌 Under the hood, Node uses libuv and a thread pool to manage async tasks. Why this matters? Because understanding the runtime means: ✔️ Better debugging ✔️ Better performance decisions ✔️ Stronger backend foundations On to Day 4 soon with my Boss Chris Nyeche 🚀 #NodeJS #BackendDevelopment #100DaysOfCode #JavaScript
To view or add a comment, sign in
-
-
TypeScript is a powerful, statically-typed superset of JavaScript that helps you write safer and more maintainable code. And this course teaches you all the fundamentals so you can start using it in your projects. You'll learn about built-in types, type annotation, arrow functions, union, literal, and nullable types, enums, interfaces, and lots more. https://lnkd.in/gwSCzXr5
To view or add a comment, sign in
-
-
✨ 𝗗𝗮𝘆 𝟭𝟳 𝗼𝗳 𝗠𝘆 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗝𝗼𝘂𝗿𝗻𝗲𝘆 🚀 Today I explored one of the most important concepts in JavaScript: the 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽. I learned why 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗶𝘀 𝘀𝗶𝗻𝗴𝗹𝗲-𝘁𝗵𝗿𝗲𝗮𝗱𝗲𝗱 𝗮𝗻𝗱 𝘀𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀, yet still capable of handling asynchronous tasks efficiently. Key ideas I understood: 🔹 𝗦𝗶𝗻𝗴𝗹𝗲-𝘁𝗵𝗿𝗲𝗮𝗱𝗲𝗱 𝗻𝗮𝘁𝘂𝗿𝗲 – JavaScript runs one task at a time on a single call stack. 🔹 𝗦𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀 𝗲𝘅𝗲𝗰𝘂𝘁𝗶𝗼𝗻 – code runs line by line by default. 🔹 𝗘𝘃𝗲𝗻𝘁 𝗟𝗼𝗼𝗽 – manages asynchronous operations by coordinating the 𝗖𝗮𝗹𝗹 𝗦𝘁𝗮𝗰𝗸, 𝗪𝗲𝗯 𝗔𝗣𝗜𝘀, 𝗮𝗻𝗱 𝗖𝗮𝗹𝗹𝗯𝗮𝗰𝗸 𝗤𝘂𝗲𝘂𝗲. This concept finally helped me understand how JavaScript handles things like 𝘁𝗶𝗺𝗲𝗿𝘀, 𝗲𝘃𝗲𝗻𝘁𝘀, 𝗮𝗻𝗱 𝗮𝘀𝘆𝗻𝗰𝗵𝗿𝗼𝗻𝗼𝘂𝘀 𝗼𝗽𝗲𝗿𝗮𝘁𝗶𝗼𝗻𝘀 without blocking the main thread. #JavaScript #100DaysOfCode #WebDevelopment #LearningJourney #FrontendDevelopment #EventLoop
To view or add a comment, sign in
-
-
Today I explored how TypeScript works internally. TypeScript code doesn’t run directly in the browser or Node.js. It first goes through the TypeScript compiler (tsc), which processes the code through several stages before generating JavaScript. Pipeline: TS Code → Lexer → Parser → Binder → Checker → Emitter → JS Code I wrote a blog explaining each stage with a simple example. Blog link: https://lnkd.in/gXkmfAsb Learning a lot from Hitesh Choudhary Sir’s content. Truly grateful for the guidance. #TypeScript #JavaScript #WebDevelopment #LearnInPublic
To view or add a comment, sign in
-
-
I resisted TypeScript for months. "It's just JavaScript with extra steps." "It slows me down." "I don't need it for small projects." I was wrong. About all of it. The moment it clicked was when TypeScript caught a bug BEFORE I even ran the code. A bug that would have taken me 2 hours to find at runtime — caught in 2 seconds at compile time. Now I refuse to start a project without it. TypeScript doesn't slow you down. It stops you from slowing yourself down. Were you a TypeScript skeptic too? What changed your mind? #TypeScript #JavaScript #ReactDeveloper #CleanCode #FrontendEngineering
To view or add a comment, sign in
-
🚀 Day 84 of My #100DaysOfCode Challenge Today I explored an interesting concept in JavaScript — Microtasks vs Macrotasks. JavaScript is single-threaded, but it can still handle asynchronous operations efficiently using the Event Loop. Behind the scenes, tasks are organized into different queues. 1️⃣ Macrotasks Macrotasks include operations like: - "setTimeout" - "setInterval" - DOM events - I/O operations These tasks go into the Macrotask Queue and are executed after the call stack is empty. 2️⃣ Microtasks Microtasks include: - "Promise.then()" - "Promise.catch()" - "MutationObserver" Microtasks have higher priority and run before macrotasks, even if they were scheduled later. Example console.log("Start"); setTimeout(() => { console.log("Macrotask"); }, 0); Promise.resolve().then(() => { console.log("Microtask"); }); console.log("End"); Output Start End Microtask Macrotask Even though "setTimeout" runs with "0ms", the Promise (Microtask) executes first because microtasks are processed before macrotasks. Understanding these small details helps developers debug asynchronous behavior and write more predictable code. Every day I’m discovering how deep and fascinating JavaScript really is. 💻✨ #Day84 #100DaysOfCode #JavaScript #EventLoop #WebDevelopment #LearningInPublic
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟑/10 – 𝐈𝐧-𝐛𝐮𝐢𝐥𝐭 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐬 & 𝐀𝐫𝐫𝐚𝐲 𝐎𝐩𝐞𝐫𝐚𝐭𝐢𝐨𝐧𝐬 🔍📃 ✨ Today I explored some of the most useful in-built functions in TypeScript (via JavaScript) that make problem-solving easier: 🔹 split (""): This method takes a string and breaks it into an array of its individual characters. It’s useful when you want to manipulate or process each character separately. 🔹 reverse (): This method reverses the order of elements in an array. When applied after splitting a string, it flips the sequence of characters. 🔹 join (""): This method takes all elements of an array and combines them back into a single string. By using an empty string as the separator, the characters are joined without spaces. Examples - 1. Palindrome 2. Reverse of a string 3. Max of an array #TypeScript#Programming #Learning#Automation#Playwright
To view or add a comment, sign in
-
-
I'm currently focusing on my backend journey 🚀 No fancy designs for now just logic, APIs, and making things actually work. Today I built a Color Scheme Generator from scratch using vanilla JavaScript. It connects to a real API, fetches live data, and displays a full color palette on the page. Small project. Big lesson. I learned: → How to call an external API with fetch() → How async/await works and why it matters → How to dynamically create and update the DOM → How to read API documentation and use it Every project teaches me something new — and I'm just getting started. 🔗 GitHub: https://lnkd.in/dVxnrRWU #JavaScript #Backend #100DaysOfCode #WebDevelopment #Learning
To view or add a comment, sign in
-
💡 Ever wondered what actually happens when you run TypeScript? As I continue diving deeper into TypeScript, I recently explored how the TypeScript compiler works internally, and it completely changed how I look at errors and code. Here’s a simple breakdown 👇 🔹 Lexer → Breaks code into tokens 🔹 Parser → Builds an Abstract Syntax Tree (AST) 🔹 Binder → Connects variables, scopes, and symbols 🔹 Checker → Validates types and catches errors 🔹 Emitter → Converts everything into JavaScript TypeScript doesn’t just “show errors” — it goes through a full pipeline to understand your code before telling you what’s wrong. Learning this made me realize: 1. Errors are not random; they’re the result of a structured process 2. Understanding the compiler helps you debug smarter 3. TypeScript is way more powerful than just “typed JavaScript.” #TypeScript #WebDevelopment #FrontendDeveloper #LearnInPublic #JavaScript #ReactJS #NextJS #ProgrammingJourney
To view or add a comment, sign in
-
-
🚀 Day 2 of TypeScript — and things are getting interesting! Today was all about making types SMARTER. Here's what I covered: ✅ Tuples — JS doesn't have them, but TS does! A tuple is like a fixed-size array where each slot has a specific data type. → const marks: number[] = [1, 2, 3] → const marks: [number, string] = [1, "Piyush"] ✅ Any — the escape hatch of TypeScript Using `any` lets a variable hold... well, anything. But with great power comes great responsibility 😅 ✅ Union Types — OR logic for types! type stringOrNumber = string | number let a: stringOrNumber = 67 // ✅ valid let a: stringOrNumber = "Piyush" // ✅ also valid ✅ Type Aliases — stop repeating yourself Create a custom type once, use it everywhere. ✅ tsconfig.json — the brain of your TS project Two things that stood out: → "target": "ES6" — tells TS what version of JS to compile down to → "noImplicitAny": true — forces you to NEVER use `any` implicitly. TS will yell at you. And honestly? That's good. 😄 Day 2 ✅ — the types are getting stronger! #TypeScript #JavaScript #SDET #LearningInPublic #CodingJourney #Testing
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