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ā¦
Hey Rizky, did you ever get it working right for keen-slider? It's giving me problems
I was cussing on the toilet, again, because Iād accidentally clicked a link on my phone while reading The Ringerās NBA coverage.
My mom would be embarrassed, Iām sure.
You see, I prefer to open links from their website in a new tab, because I donāt want to hit the Back button. Why would such a minor thing cause me to start cussing in such a compromising position?
Itās because their website is slow. If I hit the Back button, I have to wait for their site to load again, and it almost always loses my place as dozens ofā¦
You may be curious as to why a physical therapist, massage therapist, and strength coach is also an SEO & web performance expert.
Having spent the last decade in sports medicine, including several years as a full-time physical therapist (and Airbnb SuperHost who got over 500 reviews in 3 years), it was time for a change ā so I started blogging on Medium to refresh my web development skills.
You see, I started building websites professionally back in 2001, and I even built a PHP app for LiveJournal that earned a few hundred dollars in advertising income. ā¦
Array.prototype.filter()
is infinitely more powerful than Array.prototype.includes()
, while the .includes()
method is easier to read and offers much better performance.If you need to know if a JavaScript array contains an item, you have a couple of options other than just writing a for
loop.
The most obvious alternative is Array.prototype.includes()
, but using Array.prototype.filter()
might save you future refactoring.
āThe
includes()
method determines whether an array includes a certain value among its entries, returningtrue
orfalse
as appropriate.ā
ā MDN Docs
If you need to return the first matching item, youād use Array.prototype.find()
instead of .includes()
.
The more powerful .filter()
method lets you test the entire array with an arbitrary criteria, and it returns a new array of allā¦
The Pragmatic Programmers put their entire collection of textbooks about software development and web development on Medium this week.
Is this a good thing or a bad thing for web developers?
My favorite titles from the list:
I counted 142 books in the collection. Thatās a ton of content.
As I commented on HackerNews, I think this is a great opportunity for programmers to be able to find a lot more answers through organic search.
Previously youād have to know that the topic wasā¦
""
as an argument to the array .join()
method.When you call JavaScriptās .join()
(Array.prototype.join()
) method with no argument, youāre actually using a comma.
The default behavior of .join()
is to convert an array to a string with commas, so itās the same as calling .join(",")
explicitly.
When you call .join(",")
you specify that you want a string literal ","
to be the separator character, which will occur between each element. But itās the same as .join()
with no argument at all.
If you call .join("")
with the empty string ""
instead, then all of the elements will be joined together without commas.
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:
let
and const
as alternatives to var
for declaring variables in JavaScript. Because const
is not hoisted to the top of the execution context in the same way 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
).
.
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ā¦
š¤ The physical therapist who writes JavaScript šŖ Web Developer š Mentor š§ DPT š SEO Expert š React š Jamstack š¬ Ask me anything š DoctorDerek.com š