Last active
November 1, 2016 04:45
-
-
Save KinoAR/c8cbd22c093bcd35b19a803b49fd947e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//============================================================================= | |
// Strings | |
//============================================================================= | |
//String Examples | |
//String Literals | |
//Double quotes | |
var string1 = "Hello World"; | |
//Single quotes | |
var string2 = 'Hello World'; | |
//Template Literals | |
var templateLiteralString = `Hello World`; | |
//Both String Literals and Template Literals can use string methods. | |
//Repeat | |
console.log(string1.repeat(2)); //Hello WorldHello World | |
//Includes | |
console.log(string1.includes("Hello")); //True | |
console.log(string1.includes("World")); //True | |
//IndexOf | |
console.log(string1.indexOf('H')); //0 | |
console.log(string1.indexOf('W')); //6 | |
//StartsWith | |
console.log(string1.startsWith("Hello")); //True | |
console.log(string1.startsWith("World")); //False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment