• Samantha Ming Logo Samantha Ming
  • Tidbits
  • Blog
  • Courses
  • Contact
Samantha Ming Logo
  • Home
  • Tidbits
  • Blog
  • Courses
  • Contact

  • Flexbox30
  • Newsletter
  • About
  • Invite me to speak
  • Become a sponsor

# When NOT to use Arrow Functions

Arrow functions are terrific, but not suitable for all situations. Avoid them in objects because 'this' is always scoped to the parent -- which is the 'window' in this case.


  type: '🍔',
  eat: () => { // Should use function() instead
    console.log(this); // 'this' is Window, not burger
  }
}

// Avoid Arrow Functions in Objects

# Resources

  • Arrow Function No No
Code snippet of When NOT to use Arrow Functions
Download HD Image
Next Tidbit
CSS Variables
  • Share to Twitter Twitter
  • Share to Facebook Facebook
  • Share to LinkedIn LinkedIn
  • Share to Reddit Reddit
  • Share to Hacker News Hacker News
  • Email Email

Related Tidbits

  • Convert Iterable to Array using Spread in JavaScript

  • JavaScript Exponentiation Operator

  • Math.sign: How to Check if Number is Negative or Positive in JavaScript

  • 2 Ways to Repeat Strings in JavaScript

Code snippet of When NOT to use Arrow Functions

Top Tidbits

  • CSS User Select

    CSS User Select

  •  5 Way to Append Item to Array in JavaScript

    5 Way to Append Item to Array in JavaScript

  • 5 Ways to Convert a Value to String in JavaScript

    5 Ways to Convert a Value to String in JavaScript

  • How to Format Currency in ES6

    How to Format Currency in ES6

  • HTML5 autofocus

    HTML5 autofocus

  • Prevent Object Retrieval TypeError with &&

    Prevent Object Retrieval TypeError with &&

  • hi
  • javascript
  • html
  • css
  • vue
  • console
  • array
  • object
  • es6
  • string
  • number
  • code recipes

Courses

  • Flexbox30

    - Learn Flexbox with 30 Code Tidbits ✨

  • CodeTidbits30

    - 30 days of the best JS, CSS, HTML tidbits 🎄

  • Web Basics

    - Web Basics Explained with Tidbits 🍎

  • Pictorials

    - Step by Step Code Tutorials 👣


Top Articles

  • My Top 3 Favorite FREE JavaScript Courses

  • Introducing the #NotFancyAppChallenge

  • How I Got My First Developer Job Without a CS Degree

  • 3 Tips To Find The Right Bootcamp For You


Fresh Tidbits

  • Code snippet on HTML abbr Tag

    HTML abbr Tag

  • Code snippet on How to Pad a String with padStart and padEnd in JavaScript

    How to Pad a String with padStart and padEnd in JavaScript

  • Code snippet on Avoid Empty Class in Vue with Null

    Avoid Empty Class in Vue with Null

  • Code snippet on Fix Text Overlap with CSS white-space

    Fix Text Overlap with CSS white-space

  • Code snippet on How to Check if Object is Empty in JavaScript

    How to Check if Object is Empty in JavaScript

  • hi
  • Home
  • Tidbits
  • Blog
  • Courses
  • Newsletter
  • About
  • Contact

  • What I use
  • Flexbox30
  • Pictorials
  • Web Basics
  • Invite me to speak
  • Become a sponsor
© Copyright 2025. Samantha Ming