I Don’t Use JavaScript Classes At All. Am I Missing Out on Something?

functionA(functionB(value))
function flowerColour(flowerType, colour) {
return `${flowerType} are ${colour}`
}
/* Call `flowerColour` partially, setting the
`flowerType` argument to "Roses" */
const rosesAre = flowerColour.bind(null, "Roses")
console.log(rosesAre("red")) // Returns "Roses are red"
/* Map is a higher-order function, because
it takes a function as an argument */
// Returns [10, 16, 37, 9]
[20, 32, 74, 18].map(number => number / 2)
/* Another higher order function, in this
case, it returns a function */
function createLuckyNumber(name) {
const luckyNumber = parseInt(10000 * Math.random())
return function() {
return `${name}'s lucky number is ${luckyNumber}`
}
}
const emmasLuckyNumber = createLuckyNumber("Emma")
const joesLuckyNumber = createLuckyNumber("Joe")
// Returns "Emma's lucky number is 7280"
console.log(emmasLuckyNumber())
// Returns "Joe's lucky number is 2971"
console.log(joesLuckyNumber())

What Make Classes Tick

--

--

--

Your JavaScript friend! I’ve been working for over a decade in JS, and I want to help you level up your skills

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

Recommended from Medium

Tips on fast web performance with ex-Contentful Developer Evangelist Stefan Judis

KonContinue -Online Submissions

Day 62 Training at Ryaz: Project Completed.

A To-do List App with React (2): Basic Concepts of React (Components / JSX)

Cooking unit tests in React Native

Playing ESP32 is Easy and Fun![Web Server]

Get it right, or try again and again.

Easiest way to learn Custom Hooks

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
Nico Zerpa

Nico Zerpa

Your JavaScript friend! I’ve been working for over a decade in JS, and I want to help you level up your skills

More from Medium

On the ‘new’ keyword in Javascript

How to Display a Current Date in Various Format in JavaScript

localStorage and sessionStorage in JS

Banner

What is JavaScript?