Lädt...


🔧 Day 59 / 100 Days of Code: Reflecting on Arrow Functions


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Wed, August 28, 2024

As I wrap up the 14 mini-projects, there’s one more assignment before tackling the number guessing game. Throughout this journey, I’ve found AI incredibly helpful for getting feedback on my coding style.

I’ve had a question about writing functions because when given the chance I've usually written arrow function, because at my last job, arrow functions were the norm, especially during tech showcases. But despite their name, they're actually variables, or expression statements. So, I wondered if I’m missing out by not using traditional functions more often.

Here’s what Copilot had to say about the differences between arrow functions and traditional functions. These points are worth noting, even though we haven’t covered them all yet:

  • Syntax and Conciseness: Arrow functions offer a shorter syntax, making your code more readable and concise, especially for simple functions. this Binding: Arrow functions don’t have their own this context; they inherit it from the surrounding lexical context. This is useful for event handlers or callbacks where you want to maintain the context of this. Traditional functions have their own this context, which can sometimes be confusing.
  • arguments Object: Arrow functions don’t have their own arguments object. If you need to access the arguments passed to the function, you’ll need to use rest parameters (...args). Traditional functions have their own arguments object, which can be handy.
  • Constructors: Arrow functions can’t be used as constructors and will throw an error if you try to use them with the new keyword. Traditional functions can be used as constructors, which is important for object-oriented programming.
  • Methods: Arrow functions aren’t suitable for defining methods in objects because they don’t have their own this context. Traditional functions are better for this purpose.
  • In summary, while arrow functions are great for many use cases, especially for callbacks and simple functions, traditional functions still have their place. It’s good to be comfortable with both and use them appropriately based on the context.
...

🔧 Day 59 / 100 Days of Code: Reflecting on Arrow Functions


📈 67.13 Punkte
🔧 Programmierung

🔧 Day 44 / 100 Days of Code: Reflecting on My Journey to Becoming a Developer


📈 42.09 Punkte
🔧 Programmierung

🔧 JavaScript Regular/Normal vs Arrow Function: My Beef with Arrow Functions.


📈 39.66 Punkte
🔧 Programmierung

🔧 Draft: What are the differences between arrow functions and traditional functions?


📈 35.48 Punkte
🔧 Programmierung

🔧 Why the "this" Keyword Behaves Differently in Regular Functions and Arrow Functions


📈 35.48 Punkte
🔧 Programmierung

🔧 7 Differences Between Arrow Functions and Traditional Functions


📈 35.48 Punkte
🔧 Programmierung

🔧 JavaScript Arrow Functions vs Regular Functions


📈 35.48 Punkte
🔧 Programmierung

🔧 Arrow Functions vs. Regular Functions in JavaScript: A Comprehensive Guide


📈 35.48 Punkte
🔧 Programmierung

🔧 The difference between Arrow functions and Normal functions in JavaScript


📈 35.48 Punkte
🔧 Programmierung

🔧 🚀 JavaScript Functions: Arrow Functions, Callbacks, and Closures 📜


📈 35.48 Punkte
🔧 Programmierung

🔧 Understanding Arrow Functions vs. Normal Functions in JavaScript


📈 35.48 Punkte
🔧 Programmierung

🔧 Arrow Functions vs. Regular Functions in JavaScript: A Showdown


📈 35.48 Punkte
🔧 Programmierung

🔧 Mastering JavaScript Functions: Your Guide to Normal vs. Arrow Functions


📈 35.48 Punkte
🔧 Programmierung

🔧 Day 51 / 100 Days of Code: Exploring the Versatility of JavaScript Functions


📈 32.48 Punkte
🔧 Programmierung

🔧 Day 46 / 100 Days of Code: Exploring JavaScript Functions and Dynamic Typing


📈 32.48 Punkte
🔧 Programmierung

🔧 100 Days of Servers Distributions- Days 4 and 100 Day 4 Introduction to Web Servers


📈 32.26 Punkte
🔧 Programmierung

🔧 Functions of Commercial Bank: Primary Functions and Secondary Functions


📈 31.29 Punkte
🔧 Programmierung

📰 Arrow Forum 2024: Arrow feiert ein großes Familienfest - channelpartner.de


📈 29.23 Punkte
📰 IT Security Nachrichten

📰 Channel-Treff in München: Arrow veranstaltet Arrow University - channelpartner.de


📈 29.23 Punkte
📰 IT Security Nachrichten

🕵️ arrow-kt Arrow up to 0.8.x Gradle Build Artifact Resolver weak encryption


📈 29.23 Punkte
🕵️ Sicherheitslücken

📰 Arrow ECS lädt zur »Arrow University«


📈 29.23 Punkte
📰 IT Security Nachrichten

🔧 🌟 Reflecting on 90 Days of Learning: My Journey So Far


📈 28.1 Punkte
🔧 Programmierung

🔧 Reflecting on my first 90 days building a startup as a technical cofounder


📈 28.1 Punkte
🔧 Programmierung

🔧 100 Days of Servers Distributions- Days 1 and 100


📈 27.83 Punkte
🔧 Programmierung

🔧 100 Days of Servers Distributions- Days 3 and 100


📈 27.83 Punkte
🔧 Programmierung

🔧 100 Days of Servers Distributions- Days 2 and 100


📈 27.83 Punkte
🔧 Programmierung

🔧 Day 53 / 100 Days of Code: Simplifying Code with Object Literals


📈 25.76 Punkte
🔧 Programmierung

🔧 Days 32-34 of 100 Days of Code


📈 25.68 Punkte
🔧 Programmierung

🔧 Days 32-34 of 100 Days of Code


📈 25.68 Punkte
🔧 Programmierung

🔧 Days 10–12 of 100 Days of Code


📈 25.68 Punkte
🔧 Programmierung

🔧 Comparing Lexical Scope for Function Declarations and Arrow Functions


📈 25.05 Punkte
🔧 Programmierung

🔧 Why you should not use Arrow Functions in JavaScript?


📈 25.05 Punkte
🔧 Programmierung

🔧 Easy JavaScript with Arrow Functions!


📈 25.05 Punkte
🔧 Programmierung

🔧 JavaScript | What Are Arrow Functions?


📈 25.05 Punkte
🔧 Programmierung

matomo