Saying “Dad” in JavaScript

From the simple to the overly complicated

Robert Mion
1 min readSep 4, 2019

String

const dad = "Dad";

Array

["D", "a", "d"].join()

Object

Object.values({
0: "D",
1: "a",
2: "d"
}).join()

Function

function say(word) { return word; }const dad = say("Dad")

Higher-Order Function and Closure

function sayWord(word) {
return function() {
return word;
}
}
const dad = sayWord("Dad")
dad()

--

--

Robert Mion
Robert Mion

Written by Robert Mion

Designer, Developer, DataViz, Dad • rmion.com

No responses yet