In early 2018, The Guardian, a British newspaper and online publication, switched its 2.3m content items from MongoDB to PostgreSQL.
Why did they switch? What would they do differently today?
In July 2015, a massive heatwave struck London, with the unusual consequence of The Guardian switching from MongoDB to PostgreSQL just three years later.
At the time, The Guardian’s data was in a standard NoSQL database; MongoDB stored locally at Guardian Cloud, the data center in the basement of The Guardian’s office near Kings Cross.
While writers for The Guardian were live-blogging about the heat, developers at The Guardian were scrambling to bring the main servers back online. …
Stackbit just released their pricing plans for their Jamstack “instant site” service, which I love and have written about before:
My initial impression is that there’s a lot of value for anyone making websites in a small team. Is it enough to make the $29 and $149 price points attractive for teams of 4 users and 10 users respectively?
I’ll still use Stackbit’s free tier any time. I mean there’s literally a Create Site button on the excellent Jamstack Themes site:
var
is, const should be faster, right?The first lecture in Tyler McGinnis’s Advanced JavaScript course covers execution context and hoisting, and it got me wondering about instantiating variables using var
and const
in JavaScript.
After the lecture, I was left thinking that the JavaScript keyword var
might be slower than the keyword const
, because var
needs to be hoisted.
Perhaps that extra step in the execution context hurts performance. If so, we would also expect to find that let
is slower than var
.
(If you’re not sure about the difference between each of these keywords for declaring variables, I’ve previously compared let
, var
, and const
).
There’s evidence that many modern JavaScript features are slower than older JavaScript code. After all, ES6 (ECMAScript 6) was released in 2015 (and thus is also called ES2015). Prior to that, we were all using ES5 — and many developers still do in order to support older browsers. …
.
dot syntax or []
bracket notation. Here’s why there are two property accessors and what the difference is between them.One of the first things JavaScript developers learn is that there is a difference between primitive types (like numbers and booleans) and objects (like arrays and Dates
).
You typically recognize objects because they are invoked with the object literal syntax ({}
, curly brackets) and then accessed using a single period character, the .
dot syntax.
Calling the .
dot syntax is what is called an object property accessor, as it allows you to access the specified property.
“Property accessors provide access to an object’s properties by using the dot notation or the bracket notation.” — MDN Docs
Object properties are also called object keys in JavaScript, as objects are defined as collections of key-value pairs. …
{}
to declare objects in JavaScript. Writing out a new object this way is called creating an object literal, which means curly braces {}
are the object literal syntax.In JavaScript, there are a bunch of ways to make new objects, but we almost always use the object literal syntax, {}
.
“Objects can be initialized using
new Object()
,Object.create()
, or using the literal notation (initializer notation). An object initializer is a comma-delimited list of zero or more pairs of property names and associated values of an object, enclosed in curly braces ({}
).” — MDN Docs
When we write curly brackets {}
, we create an empty object with no properties, which is the same as calling the Object()
constructor with the new
keyword: new Object() // same as {}
.
We often want to specify certain object properties (also called object keys) at the same time that we create a new object. …
JavaScript objects are collections of key-value pairs, where each object key (also called object property) has a specific value.
Object keys are strings (or symbols), but values can be all different types, including arrays and objects.
If you need to use any primitive type (or object reference) as the object key, you should use a Map
instead of an object.
We typically write JavaScript object properties using camelCase, without spaces, but you can use spaces in keys if you prefer. Just be sure to include quotation marks to specify the string you’re using as the object key.
Here’s a code example of a JavaScript object key containing a space, myObject["hello…
Out there applying for a web developer job? It never hurts to ask your friends if their companies are hiring. But how do you actually make a positive impression on the hiring manager?
All companies want you to answer the question, “Why should we hire you?” For web developers, that means demonstrating real-world technical skills before you even get to the interview.
Here are 10 great tips to help you land your next position.
Tried and true, adding a new portfolio project is a great way to buff up your real skills at the same time as you show them off. …
{}
seems self-obvious: there are no user-defined object properties (also called object keys). But how exactly do you check if an object is empty in JavaScript?{}
Have Length 0?Unlike arrays, generic JavaScript objects have no .length
method to check for the number of entries (object key-value pairs).
That means knowing whether you have an empty object {}
is not an obvious task — how do you check an object’s “length”?
Here are 4 methods to check whether a JavaScript object is an empty object, meaning it is empty of object keys (object properties).
.length
of an Array of Object.keys()
.length
of Object.getOwnPropertyNames()
for...in
loop with .hasOwnProperty()
I’ll include short JavaScript code examples as we go along, comparing each method to check if an object is empty. …
localStorage
inside a user’s web browser. Local storage is also known as HTML5 localStorage
, window.localStorage
, or the browser’s cache.localStorage
in JavaScript?When we call window.localStorage
in JavaScript, we are able to store data that persists on the client’s browser and accessible from client-side code running in that browser.
That means when the user leaves the site and comes back to it later, your JavaScript code can read from window.localStorage
.
“The read-only
localStorage
property allows you to access aStorage
object for theDocument
's origin; the stored data is saved across browser sessions.” — MDN Docs
Users like being able to pick up where they left off at, all the more so without needing an account or login of any type.
The data in localStorage
persists between sessions of the browser, even if the browser is closed, unless the user clears the cache. …
=
). Instead, you need to learn the rules for the delete
keyword, which removes object keys.delete
to Remove Object KeysThe special JavaScript keyword delete
is used to remove object keys (also called object properties).
“The JavaScript
delete
operator removes a property from an object; if no more references to the same property are held, it is eventually released automatically.” — MDN Docs
While you might think setting an object key equal to undefined
would delete it, since undefined
is the value that object keys that have not yet been set have, the key would still exist.
To actually remove the key from the object, you need to use the delete
keyword, as we see in this JavaScript code example:
About