Daniel Escobedo

From the Command Line to the Text Editor - Personal Notes in Software Engineering

JavaScript Promises

A simple metaphor I've heard used before is that a Promise in JavaScript is like ordering a cheeseburger at a fast food restaurant. When you pay for the cheeseburger, they give you a receipt with an order number on it. That receipt represents a placeholder...

React Component Lifecycle Methods

There are only 4 different events that can trigger React component lifecycle methods: When a Component Mounts A component will only mount once during its lifecycle. The following 2 methods are only called once in the component's lifecycle alongside the component's render(): * componentWillMount() * render() * componentDidMount(...

Testing for NaN in ES6

Reliably testing for NaN has become much simpler (and safer) in ES6 using Number.isNaN( x ): a = "foo" * 2; b = "bar"; Number.isNaN( a ); // true Number.isNaN( b ); // false How is this different than the current isNaN( x )? We are trying to test for, and...

Reversing a JavaScript String

JavaScript strings do not have in place mutator methods like arrays do: var arr = [ 'f', 'o', 'o' ]; arr.reverse(); arr; // Array [ 'o', 'o', 'f' ]; Since strings are immutable, we need a hack to accomplish the above with a string: var str = 'bar'; str.split('')...

Mastodon