-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path03_strings.js
More file actions
21 lines (15 loc) · 787 Bytes
/
03_strings.js
File metadata and controls
21 lines (15 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//Strings
//Strings in JavaScript are sequences of characters. More accurately,
//they are sequences of Unicode characters, with each character
//represented by a 16-bit number. This should be welcome news to
//anyone who has had to deal with internationalization.
//If you want to represent a single character, you just use a string of length 1.
//To find the length of a string, access its length property:
"hello".length; // 5
//There's our first brush with JavaScript objects! Did we mention
//that you can use strings like objects too? They have methods as
//will that allow you to manipulate the string and access information
//about the string:
"hello".charAt(0); // "h"
"hello, world".replace("hello", "goodbye"); // "goodbye, world"
"hello".toUpperCase(); // "HELLO"