OddPen

Welcome to my blog where I write mostly about technical things!

Welcome to the series about destructuring a JavaScript quiz from Social Media. This Sunday, you'll learn about the one API you should never use: eval.

⚠️ Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you use eval(). Read more at MDN

The Snippet

function challenge(input){
  eval(input.toUpperCase())
}

// provide an input that makes function challenge call alert(1)
challenge('alert(1)');
Read more...

Welcome to the series about destructuring those over-shared JavaScript quizzes on Social Media. Have fun digging into default values!

The Snippet

let year = 2020;
const evolution = (defaultYear = 2000) => {
  year = defaultYear;
}
evolution(null);
console.log(year);
Read more...

Welcome to my series about destructuring those JavaScript quizzes on Social Media. Enjoy the fifth episode!

The Snippet

let arrOne = [8];
let arrTwo = [9];

console.log(arrOne == 8);
console.log(arrTwo == 9);
console.log(arrOne < arrTwo);
Read more...

Welcome to my series about destructuring one of those frequently shared JavaScript quizzes on Social Media. This is the fourth episode featuring one of the oldest JS tricks!

The Snippet

console.log(0.1 + 0.2);
console.log(0.1 + 0.2 == 3);
console.log(0.1 + 0.2 === 3);
Read more...

Peer reviews are a broad topic with infinite things to learn and discuss. And they can be scary, especially when you have just started your professional tech career. In this post, I will share some thoughts on the worst (is it?) thing that can happen: your PR is ripped into pieces.

Read more...

Another episode in my series about destructuring JavaScript quizzes from Social Media. This time we try to guess the length of a very special string!

The Snippet

const stars = `
  ⭐
  ⭐⭐
  ⭐⭐⭐
  ⭐⭐⭐⭐
  ⭐⭐⭐⭐⭐
`;

console.log(stars.length * 2);
Read more...

Let's destructure a social media code quiz about hoisting in this second episode of my series. 🎉

The Snippet

function fooBar() {
  try {
    console.log(foo);
  } catch (error) {
    console.log(error.name);
  }
  try {
    console.log(bar);
  } catch (error) {
    console.log(error);
  }
  var foo = 'hello';
  let bar = 'world';
}

fooBar();
Read more...

This is a series where I (quickly) destructure one of those often shared snippet quizzes on Social Media. Welcome to the first episode!

Snippet

const myList = [['❤️'], ['JSSnippets'], ['❤️']];
const mySet = new Set(myList);
console.log(mySet.size);
Read more...

I just wanted to share a quick tip I learned on Twitter a while ago. It was about how you can wrap curly braces around a variable in your console.log statements to transform it into an object and have the variable name automatically prefixed.

Read more...

The problem with one-line arrow functions is that if you want to debug them with console.log, it's fairly annoying since you have to add curly braces and a return statement.

Read more...