Sign Up Now!

Sign up and get personalized intelligence briefing delivered daily.


Sign Up

Articles related to "javascript"


A cartoon intro to WebAssembly (2017)

  • WebAssembly is a way of taking code written in programming languages other than JavaScript and running that code in the browser.
  • So when people say that WebAssembly is fast, what they are comparing it to is JavaScript.
  • Multiple browsers added just-in-time compilers, also called JITs. As JavaScript was running, the JIT could see patterns and make the code run faster based on those patterns.
  • The introduction of these JITs led to an inflection point in the performance of JavaScript.
  • With this improved performance, JavaScript started being used for things no one ever expected it to be used for, like server-side programming with Node.js.
  • The performance improvement made it feasible to use JavaScript on a whole new class of problems.
  • So, let’s dive into the details to understand what makes WebAssembly fast.

save | comments | report | share on


Form Validation: You're (likely) doing it wrong

  • Unfortunately though, as written, the above will correctly display an error if the first field is tabbed through, but then if trying to shift-tab back to correct that error, it will annoyingly display an error for the second field.
  • This sort of thing is covered in the above-referenced article.
  • I've created a Gist containing the above code, both revisions being available here.

save | comments | report | share on


Real world testing: Using business and technical requirements to know what to test

  • When you go to implement this in code, chances are you aren't going to just write a test that says "should be able to log into application" (although this would make for a good end-to-end test, which I will get into a little bit later) before you've broken that down a bit.
  • What you'd likely do instead is break that down into some technical/code requirements, like "OK, if a user should be able to log into an application, first I need to have a server route that checks their username/password and logs them in.
  • Referring back to the previous example of a user being able to log in to the application, I mentioned that although the base requirement was broad and we probably wouldn't write our first tests based on that alone.

save | comments | report | share on


HTTPS In Development: A Practical Guide

  • Keep reading to know why and how to serve a JavaScript application with HTTPS on your development environment.
  • On a development environment, we can use a reverse proxy, too!
  • This configuration tells Traefik to handle HTTPS requests to https://localhost and proxy each of them to http://localhost:8080 in order to serve static files.
  • The first one redirects to the HTTPS, and the second is configured to encrypt requests thanks to the specified TLS certificates.
  • Sometimes security requirements demand end-to-end encryption, or having a reverse proxy just might seem to be overkill on a development environment.
  • Most of the time, it's possible to serve HTTPS directly from your everyday development environment.
  • If you want to use your own HTTPS certificate (signed with an authority that your browser trusts), create-react-app doesn't let you configure it without ejecting the app (npm run eject).

save | comments | report | share on


Typescript Dependency Injection in 200 LOC

  • Like Anders mentions in his talk, Typescript at the time was missing two crucial features which AtScript was meant to address; Decorators and Reflection.
  • Traditional pure javascript containers would use hacks like casting the function or class to a string and manually parsing that string to get the names of each parameter/property.
  • To combat this, Typescript uses a library called reflect-metadata to store additional type information.
  • Tokens can either refer to a class or, in cases where the parameter type doesn't give enough context about what to inject, a constant attached to a parameter with a decorator.
  • We use the assertInjectableIfClassProvider method to make sure all the classes which are provided to the container have been marked as Injectable, and therefore have metadata.
  • We invoke the reflect-metadata API in order to get a list of types for each parameter of the constructor.

save | comments | report | share on


Can I Use React Hooks Yet?

  • Now everyone is going to immediately switch their syntax style over to this immediately, but by making yourself go through a couple of refactor sessions, you will pinpoint the easy and hard places to change.
  • Instead and as you can see in the Refactored StackBlitz Demo, we can create the state variable and it's update method in the same call we make to useState().
  • update our component to call this new changeValue() function and we have made the demo much simpler than before using basic Hooks.
  • It's a gateway drug to the more advanced stuff you can do and an eye opening experience that makes me feel so glad to be a react developer and have the time to research and learn it is so valuable to me.
  • I'm so happy that React took it's time with this and it feels like they hit a home run here with Hooks.

save | comments | report | share on


What goes through my mind while writing a function 😡

  • I don't think a week goes by without me writing a function.
  • each time I write a function, I keep stumbling upon so many questions.
  • It will help when I am going to write the tests, and maybe I could even reuse the function somewhere else.
  • But now I am writing the function I notice myself referring to this.state and this.props.
  • Maybe I can cut up the function in smaller pieces.
  • Some of the stuff I'm writing can be pure and modular, while the rest of the function can be a bit like an impure container giving out the orders.
  • I remember I have a few other functions in the app that will definitely benefit from some of the stuff I have just written.
  • Let's hook those up to my small functions and start abstracting!
  • I decide to write the function step-by-step, documenting my choices.

save | comments | report | share on


Form Validation: You're (likely) doing it wrong

  • Unfortunately though, as written, the above will correctly display an error if the first field is tabbed through, but then if trying to shift-tab back to correct that error, it will annoyingly display an error for the second field.
  • This sort of thing is covered in the above-referenced article.
  • I've created a Gist containing the above code, both revisions being available here.

save | comments | report | share on


Can I Use React Hooks Yet?

  • Now everyone is going to immediately switch their syntax style over to this immediately, but by making yourself go through a couple of refactor sessions, you will pinpoint the easy and hard places to change.
  • Instead and as you can see in the Refactored StackBlitz Demo, we can create the state variable and it's update method in the same call we make to useState().
  • update our component to call this new changeValue() function and we have made the demo much simpler than before using basic Hooks.
  • It's a gateway drug to the more advanced stuff you can do and an eye opening experience that makes me feel so glad to be a react developer and have the time to research and learn it is so valuable to me.
  • I'm so happy that React took it's time with this and it feels like they hit a home run here with Hooks.

save | comments | report | share on


Can I Use Hooks Yet?

  • Now everyone is going to immediately switch their syntax style over to this immediately, but by making yourself go through a couple of refactor sessions, you will pinpoint the easy and hard places to change.
  • I can swap that class style StackBlitz demo over to Hooks by simply installing npm i [email protected] [email protected] and importing: import React, { useState } from 'react';.
  • Instead and as you can see in the Refactored StackBlitz Demo, we can create the state variable and it's update method in the same call we make to useState().
  • update our component to call this new chagneValue() function and we have made the demo much simpler than before using basic Hooks.
  • It's a gateway drug to the more advanced stuff you can do and an eye opening experience that makes me feel so glad to be a react developer and have the time to research and learn it is so valuable to me.

save | comments | report | share on