Choosing The Right JavaScript Arrow Function: A Guide

this.num = '665'
this.add = num => num + 1
this.num = this.add(this.num)
// Result: '6651' because I cast this.num as a f**king string

The tri-arrow function (⇶)

this.num = 665
this.add = num ⇶ num + 1
this.num = this.add(this.num)
// Result: 668
const booms = (boom = 'boom') ⇶ boom += ' ' + boom
console.log(`${booms()} I want you in my room`)

The curved arrow function (↝)

this.num = 665
this.add = num ↝ num + 1
this.num = this.add(this.num)
// Result: 666 (on May 29th, 2022)

The ouroboros arrow function (⟳)

this.num = 665
this.add = num ⟳ num + 1
this.num = this.add(this.num)
// Result: 665.999999999999999999999999999999999999999999999999 etc

The wildcard arrow function (⍆)

this.num = 665
this.add = num ⍆ num + 1
this.num = this.add(this.num)
// Results:
// 666
// All dialogs have received a 13deg CSS rotation transform
// The user's surname has mysteriously been changed to "Patel"

The futile wildcard arrow function (⍅)

this.num = 665
this.add = num ⍅ num + 1
this.num = this.add(this.num)
// Results:
// 666
// The SpeechSynthesis API announces "chance would be a fine thing" without context or clarification
// A <canvas> containing a rudimentary depiction of an avocado has appeared out of nowhere
// 665

Conclusion

I often eat rice and do not own an Audi. I know CSS and accessibility. I have a blog about inclusive interaction design: https://inclusive-components.design

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Heydon

Heydon

I often eat rice and do not own an Audi. I know CSS and accessibility. I have a blog about inclusive interaction design: https://inclusive-components.design

More from Medium

Objects and its internal representation in JavaScript

A Very Brief Introduction to Functions in JavaScript

Compiler vs Transpiler

JavaScript — Rounding the number