Check out a free preview of the full Interviewing for Front-End Engineers course

The "What is a String" Lesson is part of the full, Interviewing for Front-End Engineers course featured in this preview video. Here's what you'd learn in this lesson:

Jem dives into covering useful information that comes up in on-site interviews, and starts with strings. Jem covers some useful methods, and brings up immutability and how turning a string into an array to manipulate it can help performance.


Transcript from the "What is a String" Lesson

>> Let's start with a bit of knowledge. Let's talk about strings. What is something interesting about strings? Anything interesting at all?
>> They're primitive type.
>> Yeah, they're primitive type, yeah. Which is also deceiving because JavaScript likes to trick you. It's a primitive type, but there is also methods that are on a string that I can call.

In fact, these are some useful methods for strings. Split is useful because using split I can turn a string into an array, and then once I have the array I can do whatever I want with it. LowerCase if you're dealing with a lot of strings, having to putting them all in lowercase if you're comparing strings, things like that, just so useful nothing, no.

Substring or sub STR, depending which one you like to use to get a part of a string out of another string and starts with is amazing. It wasn't around to a couple of years ago. In the old days, maybe regular expressions and all this stuff starts with is so great ends with this.

There's such useful methods, probably the main thing I'd say to know about strings, the strings are immutable. Once you create a string, you can't change it. And if you do change it, you're actually creating another string. And it's important to know that if you're missing a lot of strings, you're actually just creating more and more strings.

So if you watch the graph, if you're doing a memory profile, you'll see the garselecter go up and down, and up and down if you're creating a lot of strings. Generally, it's useful to turn a string into an array and then manipulate it and turn it back into a string rather than creating a bunch of strings.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now