1function isString(value) {
2 return typeof value === 'string' || value instanceof String;
3}
4
5isString(''); // true
6isString(1); // false
7isString({}); // false
8isString([]); // false
9isString(new String('teste')) // true
10
1var a = "a";
2var b = "b";
3if (a < b) { // true
4 console.log(a + " est inférieure à " + b);
5} else if (a > b) {
6 console.log(a + " est supérieure à " + b);
7} else {
8 console.log(a + " et " + b + " sont égales.");
9}
1JS String Methods:
2charAt()
3Returns a character at a specified position inside a string
4charCodeAt()
5Gives you the unicode of character at that position
6concat()
7Concatenates (joins) two or more strings into one
8fromCharCode()
9Returns a string created from the specified sequence of UTF-16 code units
10indexOf()
11Provides the position of the first occurrence of a specified text within a string
12lastIndexOf()
13Same as indexOf() but with the last occurrence, searching backwards
14match()
15Retrieves the matches of a string against a search pattern
16replace()
17Find and replace specific text in a string
18search()
19Executes a search for a matching text and returns its position
20slice()
21Extracts a section of a string and returns it as a new string
22split()
23Splits a string object into an array of strings at a specified position
24substr()
25Similar to slice() but extracts a substring depended on a specified number of characters
26substring()
27Also similar to slice() but can’t accept negative indices
28toLowerCase()
29Convert strings to lowercase
30toUpperCase()
31Convert strings to uppercase
32valueOf()
33Returns the primitive value (that has no properties or methods) of a string object
1const string1 = "A string primitive";
2const string2 = 'Also a string primitive';
3const string3 = `Yet another string primitive`;