Interviewing for Front-End Engineers What is a String
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.
[00:00:26] 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.
[00:00:45] 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.
[00:01:02] 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.
[00:01:16] 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.