Learning about the DOM in JavaScript, jQuery, and More

A recap of my recent experience with an intermediate JavaScript course on Lynda.

Screenshot of Lynda course
Click the image to watch the preview for ‘The DOM in JavaScript, jQuery, AngularJS, and React’ on Lynda.com.

I recently finished an interesting course on the DOM and different versions of JavaScript. I liked that it was just a taste of JavaScript, jQuery, Angular, and React. It’s called The DOM in JavaScript, jQuery, AngularJS, and React. It was released in 2017.

Much of the course was focused on regular JavaScript. I’m glad I’ve spent so much time studying JavaScript, because a lot of basic things didn’t need to be explained for me in this course.

Although I know about the DOM, using HTML, this focus on the DOM using JavaScript was an interesting approach. For instance, traversing the DOM (with classes and IDs) was fun:

document.body.children[4].children[1]

This selects the 5th child of the body, then the 2nd child from that. This is almost like using CSS selectors to select parent and child elements.

One of the things I love about Lynda is that they recommend additional courses to learn more about related topics. A few courses the instructor recommended included:

  • JavaScript Essential Training
  • jQuery for Web Designers
  • Angular 2 Essential Training
  • ReactJS Essential Training

They may have updated it, but I’ve already taken the JavaScript Essentials course before, so I’ll check if the others are already on my list. Angular is past version 2 by now, but maybe it’s easier to get started with that version.

 

Stuff I learned about Debugging on FreeCodeCamp

I recently got through the Debugging set of lessons on FreeCodeCamp. Here are a few points I learned.

Error Types

There are 3 types of errors:

  • Syntax – misspelled word, missing parentheses, etc.
  • Runtime – detected while running the program.
  • Semantic – detected after testing output. Program works but result is wrong. Be careful!
Short List

1. Use DevTools on Chrome or Firefox

2. Use console.log(); a lot. console.log spits out the value of whatever is in the () to the browser console, which helps you keep tabs on how a value is changing in your code. Sometimes you have to move the console.log to a different place, like before or after another function, because order matters and the value of your value can change.

3. Use console.clear(); to clear the memory of a value in the console. Sometimes it’s ok to forget.

4. Use typeof to keep track of values. For instance sometimes a number is a numeral and sometimes it’s a string. Write console.log(typeof value); and that will tell you the type for value.

5. Lastly, you have to watch out for misspellings, missing brackets or parentheses, using ‘=‘ instead of ‘==‘, or getting the dreaded infinite loop.


Next in FreeCodeCamp is Data Structures!

Learning Regular Expressions (regex)

A very brief overview of regular expressions after finishing the lessons on FreeCodeCamp.org.

Last on my list of JavaScript education was most recently regular expressions, which are ways for a programmer to search for strings in text. I followed FreeCodeCamp’s (FCC) curriculum. You can find more about Regular Expressions on MDN.

The short name for regular expressions is “regex”, or “regexp”. The basic outline of a ‘regex’ goes like this, which tests if “Happy” is in thisLine:

let thisLine = "Happy happy, joy joy!"; 
let thisMatch = /Happy/; 
let outcome = thisMatch.test(thisLine); 
console.log(outcome);

The outcome is true. The test method only results in true or false.

In addition to test, you might also use match and replace. I believe those are the only 3 methods used in the FCC set of lessons.

Let’s try match. If you wanted to match “Happy”, and only “Happy”, you’d write:

let thisLine = "Happy happy, joy joy!"; 
let thisMatch = /^H[a-z]+/; 
let outcome = thisLine.match(thisMatch); 
console.log(outcome);

The outcome is [Happy]. Probably the most important part of regex is using special characters, and that’s what’s going on in this example. The special characters are shortcuts to help you search for a specific string. This examples searches for a string starting with a capital H (^H) and is following by any letter from a-z ([a-z]), and repeats the search for as long as necessary until reaching a break (like a space) (+).

An even simpler way to write the above would be to use a special character (\w) to search for any non-digit character and flags to allow upper or lower case (i), and global to search the entire string (g).

let thisLine = "Happy happy, joy joy!"; 
let thisMatch = /^H\w+/ig; 
let outcome = thisLine.match(thisMatch); 
console.log(outcome);

You can also return only non-alphanumeric or digit characters.

let thisLine = "Happy happy, joy joy!"; 
let thisMatch = /\W+/ig; 
let outcome = thisLine.match(thisMatch); 
console.log(outcome);

The outcome is [" ", ", ", " ", "!"]

There are many more examples of special characters, and I’ll be honest in admitting that I find it confusing. It took me a little while to figure out the second example above, partly because MDN separates their special characters onto different lines. Try these out in jsbin.

Anyway, regex are good to know if you need it.


From FreeCodeCamp:

Regular expressions are special strings that represent a search pattern. Also known as “regex” or “regexp”, they help programmers match, search, and replace text. Regular expressions can appear cryptic because a few characters have special meaning. The goal is to combine the symbols and text into a pattern that matches what you want, but only what you want. This section will cover the characters, a few shortcuts, and the common uses for writing regular expressions.

Stuff I Learned This Week: Jan 15-19 (actually, it’s February)

First post of 2018 is all about new resources and tools I learned in January, even though I’m writing in February.

Well, it’s a new year and it’s time to get back into writing. I had hoped to be a little more rigorous this year, as well as posting at least once a month, but I’d started writing this post way back in January and I’m just now getting to it in Feb.

So far, there are two subjects I definitely want to write about this year. The first is my experience learning front-end web development. The second is a critical commentary on UX hiring practices. I’ve started writing the second, but I just haven’t gotten the formatting quite right. I also have a few other topics waiting to the side, and I’m excited to get to those, too.

In the meantime, here are a few interesting things I learned this week (back in January).

The Current State of E-Commerce Product Page UX Performance (19 Common Pitfalls)

Now that I am working in e-commerce, I’m really interested in learning more about e-commerce experiences. The goals are a little different from web applications and digital products, but actually more straightforward. The goal is, essentially, getting out of the way of people making purchases. Although the results found on this site are hidden unless you pay, it’s still helpful to just have the names of the sites to review.

Laws of UX

Laws of UX. “Fitt’s Law”

A site that goes over many psychological principles of user experience. Some of these are also similar to fallacies or biases, such as the recency bias. One of them is not actually a “law”, and is just a renaming of Gestalt. I’m not a fan of renaming terms that have perfectly good names. But I am a fan of this concept and the site itself. It gives me ideas for the design of another site – maybe a site about goats.

Nunjucks Templating Language for JavaScript

As I explored the laws of UX site, I found that it had been built on a templating language that I was not aware existed. Nunjucks seems a lot like Pug (or Jade), in that you have a template with content chunks that get written independently and ported in via extend calls. I’m not explaining it well, but templating is amazing.

IBM has a new font

It is called “IBM Plex”. I like it, but it kind of looks like it would be the favorite font of Lt Commander Data.

Zappos Mobile App: Search with emojis

Presumably I downloaded this app because I was looking for shoes. Rain boots, really. Anyway, I was pretty (ahem) delighted to discover that you can search via emoji on the Zappos app. Here are some screen captures from my iPhone, where I’m searching for women’s dress boots.

Version Control Tools for Designers

This week I also came across some version control tools for designers. These are all for Mac computers, and specifically Sketch files. (Sketch is OK, but not great, IMO.) Abstract made the most sense to me; it seemed the closest to git. But here is the list for all 3. I haven’t used any of them.

Namasketch – Yoga For Beginners

Namasketch is a short yoga session for beginners, told in doodles. This sequence consists of ten basic poses in a six-minute flow. The goal is to help you create a strong foundation and develop a love for yoga before you move on to the next level.

A short, intro yoga class for yoga beginners.

It’s cute and friendly, using sketchy animation to demonstrate the poses. I think I might send this to my mom.

You can read more about the production process over at Product Hunt. Looks like he used a product called “Hype” which is the first I’m hearing of it. It’s only $50(!), but doesn’t sound like it’s for production, unless you have a small project like this.

Anyway, that’s what I learned! Until next time… 🙂