JavaScript Corners – Part 5

JavaScript Corners – Part 5

Here’s a quick one: let f = function() {}; console.log(f.name); // prints f This was quite unexpected to me. It’s the only time I’ve ever seen where the left-hand side of an assignment can affect the right-hand side. This only happens once. Once the anonymous function has a name, it can’t be re-named: let f …

Read More Read More

JavaScript Corners – Part 3

JavaScript Corners – Part 3

I was busy reading ES spec today, and the following question popped into my head: at what point are default parameters evaluated? To answer this question, I wrote the following script: function f(x = (console.log(‘a’), ‘b’)) { console.log(x); } f(); f(); f(‘c’); If default parameters are evaluated when the function is declared, then we would expect …

Read More Read More

JavaScript Corners – Part 2

JavaScript Corners – Part 2

I’m continuing my series on JavaScript corner cases. Last time I looked how function names interact with each other and with variable names. Today I’m looking at how parameters interact with variables. Take a look at the following code snippet: (function(x) { var x; console.log(‘x’, x); })(1); It creates a function that takes a parameter named x, …

Read More Read More

Why Types Introduce Coupling

Why Types Introduce Coupling

Last time I gave a long post about why C is complicated and JavaScript can make your code simpler and less buggy. Today I want to touch on another idea: that statically typed languages introduce a level of coupling in your program that’s unnecessary and makes maintenance harder. Imagine that I ask you to write …

Read More Read More

Why JavaScript

Why JavaScript

People who have known me for a while, and long-time readers of this blog, will know that I never used to be a fan dynamically typed languages. The static type system available in C# and C++ can help to prevent many bugs and runtime errors, and allow the programmer to add extra clarity to the …

Read More Read More

JavaScript Corners – Part 1

JavaScript Corners – Part 1

Recently I’ve been trying to write a simple JavaScript compiler, and it’s lead me to think more deeply about some JavaScript behavior that I previously would not have thought about, and I’d like to share that with my JavaScript readers. Take a look at the following code JavaScript code, and try to figure out what it outputs …

Read More Read More

Be a multiplier

Be a multiplier

You may have heard the analogy that some software engineers add productivity, while some multiply productivity. Today I’d like to dig a little deeper into this and share my own thoughts. What does it mean? For those who haven’t heard the phrase before, let me try to unpack my understanding of it. Consider a tale of …

Read More Read More