In a previous installment, we took a dive into the this
variable and how it behaves in different ES5 situations. In this installment, we’ll do the same but for so-called arrow functions, introduced in ES6.
Category: Progress
The JavaScript prototype chain
So far we’ve learned what the relationship is between an object and its constructor’s prototype
and what happens when we change properties set on the prototype
. In particular, we learned that if you try to access a property of on object, the JavaScript engine will first look in the object itself for the property, and it if doesn’t find it there it looks in its __proto__
property, which is also the constructor’s prototype
.
This leads to a good question: What happens if the property isn’t in the constructor’s prototype either? One possible answer is that the JavaScript engine gives up and says the property is undefined
. But that’s not what happens.
JS prototypes and property values
Let’s continue the investigation of JavaScript prototypes we started last time by seeing what happens when we manipulate properties on prototypes in various ways.
Continue reading “JS prototypes and property values”Designing out designers?
I’m teaching myself React, the JavaScript library du jour that’s meant “for building user interfaces.” Interestingly, it doesn’t use a templating language. Instead it offers JSX: an extension of the JavaScript language that lets you write JS code that looks very much like HTML and that can be rendered into HTML. On the surface this seems like a cool idea, but the apparent simplicity starts to break down when you want to do anything other than straight-line HTML.
Continue reading “Designing out designers?”JavaScript prototypes
This is the first in a series of posts intended as a gentle guide through the realm of JavaScript prototypes. If you’re coming here from a class-based language like Java, PHP, C#, or C++ I suggest you put aside everything you know about how objects and inheritance work in those languages. Try to treat the way JavaScript works as its OwnThing.
Continue reading “JavaScript prototypes”JavaScript and ‘this’
Keeping your head square about JavaScript’s this
variable can be a little challenging. A wonderfully concise summary on the issue is found in chuckj’s answer to a StackOverflow question (modified here to account for differences between ECMAScript 5’s strict and non-strict modes):
this
can be thought of as an additional parameter to the function that is bound at the call site. If the function is not called as a method then the global object (non-strict mode) orundefined
(strict mode) is passed asthis
.”
Let’s see what this means (pun intended?) for various scenarios.
Continue reading “JavaScript and ‘this’”Designers are developers
It’s common in the web and app development industry for stakeholders to make a distinction between “designers” and “developers”. One of the things I’ve noted about this distinction is that it opens the door to antagonistic perceptions and even behaviors between the two camps. At a conference a few years ago, in the presence of developers expressing disparaging views regarding designers, I suggested that, “Designers are developers.” The deafening silence suggested I had to explain what I meant:
What is a single-ended amplifier?
Single-ended amplifiers, whether made with triodes (as in the single-ended triode, or SET, amplifier), pentodes, or solid state devices, entered the high-end consumer audio consciousness a couple decades ago, and they continue to have a particular pull for a certain camp of audiophiles. This may lead some of us to wonder whether these folks are onto something that we should pay attention to.
However, there seems to be some confusion regarding what exactly single-ended amplifier are. So I thought I’d try to clear things up a little.
USBtiny on Debian
I was able to clear a “Warning: cannot open USB device: Permission denied” error when using a USBtiny programmer on my Debian sid system by adding the suggestion at the end of this Adafruit page.
Specifically, as root create a file /etc/udev/rules.d/99-USBtiny.rules
with the following single line:
Displays for classic Arduinos
You often hear that to work with graphic displays on the Arduino platform you need to use a Mega or other high-performance board. I got curious about how much you can actually get done on an a measly Uno and similar boards based on the classic ATmega328P. You can find the ongoing results on my wiki.
The story so far: 128×64 and smaller monochrome displays are usable. The smallest TFT displays much less so.