Dealing with Special Characters

The back slash character has special meaning in JavaScript strings. It is an escape character that allows us to enter special characters that would be difficult to enter otherwise.

Now most of my life I have been slash deficient. When someone says forward slash or back slash, I don’t know which character it is. Some have tried to explain it by telling me to imagine a person leaning backwards or forwards. But that doesn’t help me at all because I don’t know which side has the face.

Anyway, I digress. This is a back slash (\). Now we are all on the same page. This character allows escape sequences in strings that can insert special characters. JavaScript has some default escape characters, but the real power begins when you use unicode or hexadecimal character codes. To specify a hexadecimal character enter \x and then the hex code. For unicode, enter \u and then the code.

I think the biggest trick with these charaters is knowing the code to enter to get a certain character. Here are a couple of websites that have unicode and hexadecimal codes for characters:

Once you have a list of codes, most people are good to go. But if you need a little more guidance, here is a recent tutorial on special characters in JavaScript.

Which JavaScript Book has Taught me the Most?

I recently posed an interesting question to myself: Which JavaScript book has taught me the most?

Now I own many books on JavaScript. Some are specific to a framework, but most apply to vanilla JavaScript. But I didn’t limit my question to any subset of JavaScript. If it had anything to do with JavaScript, it was a candidate.

I enjoy books, so it was a fun exercise to go through each of my books and try to make a decision about which ones have taught me the most. Now to be fair, there are a few books I own that I have not finished reading. One I just purchased and haven’t even started yet. Now the whole process was very subjective, but the results were interesting; at least they were interesting to me.

In the end Douglas Crockford’s book JavaScript: The Good Parts didn’t make the cut for the final three. It was close, but I felt I needed to go with another book. Also, none of Kyle Simpson’s books made the top three. I have really enjoyed his books, but I was looking for the books that have taught me the most.

So here are the top three…

David Flanagan’s book JavaScript: The Definitive Guide was probably my top choice, not because I have sat down and read this book cover to cover, but just because how much I have referred to this book. This book is usually one of the first locations I go to when I have a question. It is a book I trust, so I usually weigh information on the internet with the information contained in this book. I’ve owned more than one edition of this book throughout the years. I think it was probably the first JavaScript book I purchased. Anyway, I’m pretty certain I have spent a good deal of time in this book and it has taught me a lot.

Next I chose JavaScript Patterns by Stoyan Stefanov. This book expanded my view of JavaScript and what it can do. Everything in this book is very practical. It is a concise book, but has a lot to offer. Some of the most important patterns I use, I first learned from this book.

My third choice was a bit of a surprise. I’ve been interested in functional programming of late, and I think that interest may have affected my choice. The third book is Functional Programming in JavaScript by Luis Atencio. Functional programming is a different paradigm from what I am used to, so obviously there is a lot to learn. Though this book is not the only source I have learned functional programming from, it has provided a good deal of information.

So there you have. My top three. Are there books you would add to the list? Which book taught you the most?

 

What the Heck is Memoization?

OK, I admit it. I went through a phase when I first heard the word memoization where I ignored that it existed. After all, what could a technique with a name like that have to offer me?

Well, I finally threw away my pride, admitted it might be valuable and spent some time learning about it. Yes, it is a technique used in functional programming, but it is a technique that can be applied to any coding paradigm. And it can be quite valuable.

So to make my penance complete, I thought it appropriate to do a tutorial on memoization.

Now don’t let the term scare you off. It really is not a complex concept. The patterns for implementing it are a bit involved, but the concept itself is pretty easy to understand.

I just published the tutorial on memoization and you can access it below. Take a look and give me your thoughts.

JavaScript Problems…

I’ve started a new type of tutorial on the YouTube channel: JavaScript Problems.

Every so often I want to do a tutorial which is simply presenting a problem that needs to be solved in JavaScript and then going through the process of solving it. Usually, I will present more than one way to solve the problem because I think that is great way to learn JavaScript: look at different solutions.

In the first tutorials I created, I used some problems found in some of the many JavaScript books I have access to. However, I would also like to include problems you are thinking about. So this is a chance for you to shoot me over some problems. It may end up in the next JavaScript Problem I choose to record.

To submit ideas, you can add a comment to this post, you can send an email to shancock@allthingsjavascript.com or you can add a comment to one of the YouTube videos.