DEV Community

Cover image for JS Fairy Tales #3 The Emperor’s New Literal Clothes
Pelayo Méndez
Pelayo Méndez

Posted on

JS Fairy Tales #3 The Emperor’s New Literal Clothes

Once upon a time, there was a very vain emperor who spent all day looking in the mirror. One day, a group of tailors visited the kingdom and requested an audience with him…

“Your majesty,” said the tailors, “we would like to offer you the most marvellous suit in the world.”

“What makes this suit so special?” asked the emperor.

“It will be the most beautiful suit in the world,” replied the tailors, “but it will be invisible only to the foolish.”

The emperor, intrigued, bought the suit and the tailors got to work.

const suit = {}
Enter fullscreen mode Exit fullscreen mode

After a while, the emperor was eager to see his suit but at the same time too afraid to see it. He was not sure if it would be invisible to him, so he decided to send one of his ministers. When the minister got to the loom, the tailors showed him the mannequin stated and praised every single detail. The minister cleaned his glasses several times, but he could not see anything at all and realised that the tailors were trying to swindle the emperor. However, worried that everyone would take him for a fool he decided to pretend. He approached the mannequin and evaluated the parts of the suit one by one.

const suit = {
  shirt: null,
  trousers: undefined,
  shoes: ''
}

function evaluateSuit() {
  return (
     suit.shirt === undefined && 
       suit.trousers === undefined &&
     shirt.shoes === undefined
  )
}

if(evaluateSuit()) {
    console.log("You phonies.")
} else {
  console.log("Such a marvellous fabric!")
}
Enter fullscreen mode Exit fullscreen mode

“Such a marvellous fabric. Such beautiful colours,” he concluded.

A few days later, the tailors asked the emperor for more gold to continue their work. The emperor decided to send a different minister to check how the work was going before giving them any more money.

When he got to the workshop, the same thing happened to him. He could not see anything, but he thought that if he said exactly what he saw, everyone would laugh at him. He got closer to the suit and pretended to go over each of its parts.

const suit = {
  shirt: null,
  trousers: undefined,
  shoes: ''
}

function evaluateSuit() {
  return (
     suit.shirt == null && 
       suit.trousers == null &&
     suit.shoes == null
  )
}

if(evaluateSuit()) {
    console.log("I can’t see a suit.")
} else {
  console.log("Stunning! A work of art!")
}
Enter fullscreen mode Exit fullscreen mode

“Stunning! A work of art!” he exclaimed.

After receiving news from his emissary, the emperor could not wait any longer and decided to go with his cohort to see the work of the tailors. On arriving at the workshop, he looked at the mannequin that supposedly bore the suit made by the tailors repeatedly. He could not see a suit, but nevertheless he approached it, and with a smile on his face pretended to evaluate every single detail…

const suit = {
  shirt: null,
  trousers: undefined,
  shoes: ''
}

function evaluateSuit() {
  return (
    typeof suit.shirt === 'undefined' || suit.shirt === 'null' &&
    typeof suit.trousers === 'undefined'|| suit.shoes === 'null' &&
    typeof suit.shoes === 'undefined' ||  suit.shoes === 'null'
  )
}

if(evaluateSuit()) {
    console.log("You phonies.")
} else {
  console.log("Magnificent! Superb!")
Enter fullscreen mode Exit fullscreen mode

"Magnificent! Superb! Deserving of an emperor like me!" he exclaimed, enthused.

The tailors then offered to dress him so he could go for a walk in his new suit. When the emperor was dressed, he walked onto the street and went for a stroll down the main avenue of his kingdom. Citizens, one after another come out for their houses to contemplate their king and praised the beauty of his suit. Amongst the endless tributes, the voice of a little boy could be heard who shouted:

const suit = {
  shirt: null,
  trousers: undefined,
  shoes: ""
}

function evaluateSuit() {
  return (
    !suit.shirt &&
    !suit.trousers &&
    !suit.shoes
  )
}

if(evaluateSuit()) {
    console.log("What a magnificent suit!")
} else {
  console.log("But he’s completely naked!")
}
Enter fullscreen mode Exit fullscreen mode

“But he’s completely naked!”

Then, the entire city began to laugh at the emperor, but the monarch, pretending to be in the right, carried on walking with his head held high.

Top comments (1)

Collapse
 
shiffletts38788 profile image
Shifflettson Niccum • Edited

JS Fairy Tales #3, "The Emperor’s New Literal Clothes," is a whimsical journey into the world of JavaScript, much like Larimars website, known for its exquisite range of jackets, wallets, and more. In this tale, we encounter the humorous yet instructive narrative of a JavaScript Emperor who embraces the latest language features, including template literals, only to realize their code's transparency, much like the clarity and quality of Larimars products. Through entertaining storytelling, readers and shoppers alike can explore the enchanting world of both JavaScript and fashion, uncovering the magic that lies beneath the surface, whether it's the hidden power of code or the artistry of customized jackets and accessories, all waiting to be discovered.