showing results for - "strings in javascript"
Till
22 May 2018
1var abc = "abcdefghijklmnopqrstuvwxyz";
2var esc = 'I don\'t \n know';   // \n new line
3var len = abc.length;           // string length
4abc.indexOf("lmno");            // find substring, -1 if doesn't contain 
5abc.lastIndexOf("lmno");        // last occurance
6abc.slice(3, 6);                // cuts out "def", negative values count from behind
7abc.replace("abc","123");       // find and replace, takes regular expressions
8abc.toUpperCase();              // convert to upper case
9abc.toLowerCase();              // convert to lower case
10abc.concat(" ", str2);          // abc + " " + str2
11abc.charAt(2);                  // character at index: "c"
12abc[2];                         // unsafe, abc[2] = "C" doesn't work
13abc.charCodeAt(2);              // character code at index: "c" -> 99
14abc.split(",");                 // splitting a string on commas gives an array
15abc.split("");                  // splitting on characters
16128.toString(16);               // number to hex(16), octal (8) or binary (2)
17
Lakyn
12 Jan 2019
1String(thing)
Emelie
21 Jan 2020
1`hello world`
2`hello!
3 world!`
4`hello ${who}`
5escape `<a>${who}</a>`
Lorenzo
22 Nov 2017
1var x = "SAMER";
Selim
01 Mar 2019
1return 'cat'.charAt(1); // returns "a"
2
Chiara
12 Aug 2019
1// Making Strings
2let color = "purple";
3
4// Single quotes work too:
5let city = 'Tokyo';
6
7//Strings have a length:
8city.length; //5
9
10//We can access specific characters using their index:
11city[0]; //'T'
12city[3]; //'y'
13
14// String methods:
15'hello'.toUpperCase(); // "HELLO";
16'LOL'.toLowerCase(); // "lol"
17'    omg  '.trim(); // "omg"
18
19// String methods with arguments:
20// ==============================
21
22//indexOf returns the index where the character is found (or -1 if not found)
23'spider'.indexOf('i'); //2
24'vesuvius'.indexOf('u'); //3 - only returns FIRST matching index
25'cactus'.indexOf('z'); //-1 not found
26
27// slice - returns a "slice" of a string
28"pancake".slice(3); //"cake" - slice from index 3 onwards
29"pancake".slice(0, 3); //"pan" - slice from index 0 up to index 3
30
31// replace - returns a new string, with the FIRST match replaced
32"pump".replace("p", "b"); //"bump" - only replaces first "p"
33
34// String Template Literals
35// Use backtick characters, NOT SINGLE QUOTES!
36// ========================
37const color = "olive green";
38const msg = `My favorite color is: ${color}` //"My favorite color is: olive green"
39
40const str = `There are ${60 * 60 * 24} seconds in a day`//"There are 86400 seconds in a day"
queries leading to this page
in strings javascript 22 2f 3d 22 js stingjavascript string 3f 3astring ln js 2b string javascriptoperations on strings jsdefine string in javascript with examplejavascript use string string javascriptjs string methodsstring with in javascriptwork with strings in javascriptstring 28 29 javascriptworking with strings in javascriptjavascript string 60 60using string in jswhat are strings in javascriptstring javascriptstring with 21 21 jshow to use string in javascriptjavascript string 27javascript stringsdo string in javascriptmdn string methodjavscript stringsstring in javascriptstring javascriptfunctions on strings in javascripthow to use 5c in javascript string 24 28 27string 27 29 3b javascriptjavascript string w3schoolsjs string 5cjavascript text stringscan i use 60 for string in jsstrings javascript string js ways to write strings jsstring in jsjs string 28 29string string javascriptjs stirngstring js instring mdn jsjs string 24 7b 7djavascript string methodjs string mdnjavascript text commandstring string 5bi 5d jsstrings en javascriptstring in java script 21 a string in javascripthow to js stringbasic javascript stringsjava script cheat sheetstring java script 60 string syntax javascripthow to use strings with function in javascripthow to use to string method in jsstrings in function jshow to work with strings in javascript 21 string javascriptstr jsfunction with string javascriptfunctions string in javascriptjs string 2fstring in javascrip 5btsting methods javascroptjavascript 2b stringw3 js stringjs string definitionjavasctript stringstring function in js w3js string w3schoolsdefine a string in javascriptjavascript cheatsheet js stringstring jswhat is a string in javascrioptstring in javascript example 2bstring js 7b 7d in strings js 22https 3a 2f 2f 22 string javascriptstrings in jsfunction string in javascriptstring function in javascriptjs 2astringsstring method in jsfunction with string in javascript 22 string javascriptw3schools js string functionsstring in functions javascriptstring 24 7b 7d javascriptjs string funcitonsstring javascript definition 2f in javascript stringjavascript sting 21string in javascript 5c 27 string jsjs string 25string javscriptstring functions jsstring in jjavascript string w3schoolwhat is string in js 3d string in javascript 22string 22 javascriptstring js with 22all about string in javascriptwhat is a string in javascriptstring function js examplejavascript 25stringjs stringposstring function javascript string in javascript str javascriptjs define stringjavascript 2fstring 2fstring functions in javascriptstring functions in javascript mdnstrings in js arejavsscript string 7b 7djavascript function for stringstring with string jsjs string functionsdefine string javascript 3cstring 3e javascript 5c string jsjs string 3dstring keyword javascript string jsstring operation jsjavascript string mdnjava script basik cheat sheeetwhat is stringin jsjavascript string 24javascript string manipulationstrings methods jsstring object in javascriptjs string 22 22 22 22methods on strings javascriptwhat is string in javascriptjavascript string 22javascript string definejs stringjs stringsjavascript string 24 7b 7dstring in javascriptjs object 3f stringjavascript 2bstringmdn string functionshow to define a string in javascriptstring method javascript 3d string javascriptjavascript string 5cjavascrip 5bt stringmake method of string javascriptjavascript string operatorsstrings in javascriptstring 5b 5d javascript 5c string js 5c 21 3d string javascriptjavascript string functionstring in function javascriptwhat is stri g manipulations in javascriptjavascript 2f stringsstring w3 javascripthav string h 3djsjavascript string 5dwhat is string manipulation in javascriptdom string javascriptstring operations in javascriptjs string w3str 5bi 5d javascriptjavascript 5bstring 5d 2astring javascriptmdn string 7c 7c string jsjavascrit stringjavascript for stringjs cheatsheatjavacript string methodsjavascript string 24 60 60js 5b stringfunction in string javascriptmdn js stringmethodshow to use 5c in a string jsstring jsjs metodos stringjavascript 60 stringhow to use strings in jsmdn string javascriptjs 24 stringjavascript stringmdn javascript strings methodsstring javascript mdnjavascript string 7cstring 2bjavascriptjs stingjs html stringjavascript string methidsw3schools js string methodsmdn string methodsjava script 25 stringhow can strings have properties in javascriptstrings and string in javascriptstring 21 3d string jsjava script stringjavascript 24 stringjs stringjs string a string in javascriptjs 23 string string in jsjs 5b string 5djavascript 3a stringstring 28 29 in javascriptstring 24 jsjs string stringhow to write strings in javascripta string javascriptstring 5b 5d jshex to stringjs string in stringsstring class jshow to define string function in jsmetho string js 24 string javascriptstring js 22 60string syntax js 22 3c 3e 22 string jsjavascript stringsjavascript method string javascript stringjs 24stringjs string injs 2a stringstring function jsstring manipulation in javascript js infostring methods in hsjavascript strings in javascriptjava script stringswhat are strings in jsstring 28 js 29js string methodstring in method in javascriptjavascript 5c 2a stringsting in jsstring 28 29 function jsstring methods jshow to 5c in a string jsjavascript string stringstring htmljavascript string string 3d stringjs stringstring 28 29 in jsstring string javascripthow to define string in jsjs sting functionstring functions javascriptstring code jsstrings function in javascriptjs string functionhow to use 27 in javascript stringjavascript string lithow to use 24 in javascript stringjavascript string 5b 5djavascript and stringsjavascript string example string in javascriptjs string c2 a8 22 22 js stringworking with strings javascriptwhat is a string in jsdefine string js 60string syntax javascriptsyntax string javascriptstring in javascript w3schoolsbn js stringjs value stringfunction string javascript string keyword in javascriptjs string 5b 5dcheatsheet for javascriptusing strings in javascriptjavascript function stringjs stringjavascript string 2fjavascript string 3f 27string 27 jsstring javaxriptjs cheatsheet 24 in javascript stringjavascript mdn stringjavascript use stringsjs strmdn javascript string methodsmdn string jsstring 28 29 javascriptjs string 3c stringop string in jsstring in jasjavascript string 28 29 60 60 strings javascriptjavascript string keyworddefine string in javascriptstring methods injsstring 3e jswhat is a string javascriptjs string methondsstring method in the javascirptmdn js docs string 7b 7d string jsjavascript class stringstring at javascriptjavascript string methods listsome string in javascriptstring methods mdn javascriptstring string jsjavascript string functionsstring methods javascript mdnmethod string jsjs string objectstring in javascripjavascript 2b string mdn js stringdefine strings in javascriptjavascript 60string 24string manupation jsjavascript character methodsjavascript string object 27 22 27 21 3d 22 27 22 js stringstring js with 5cstring and javascriptjs 5c stringjavascript string javascript stirng 27 21 3d 22 js stringall string js functionsstring 2a jsjavascript common string mehtod 21 string jsstring 22 in javascriptjavascriptr stringjavascript 24 7b 7d stringjs string string jsworking with strings javscriptstring javascript w3schoolsjs string 24javascript string with 5cstrings js mdnstring js 5c 5c string javascript string jsstring mdnjacvscript stringjs strings functions 27string 5c 27 jsjs 7bstring 7djs 60 stringwhat is string in jhsjs string mdmjavascript functions cheat sheetjs string 5bi 5dstring jsjavascript strigygjava script string functionsstrings jsfunction string jsstrings functions javascriptstring at jsjs string metstring in string javascriptstring example in javascriptjavascript string 27 27 27javascript 21 21stringstring methods mdnjavascript string 60 60string 60 in javascript 2f string in javascriptshorthand for javascript cheatsheetnode string manipulationjs string stringstring method jsin js stringwhat are the string functions in jsstring javascript 5cstring with javascriptjavascript string injavascript 27string 27 24 7b 7dstring in jsjs string w3 schooljavascript string with 22 22javscript string functions 24javascript stringjavascirptt stringjavascript 40 stringwhat is use string in jsdefine string js 5estring mdn javascrioptuse string in jsstring keyword jsjavascript string 7c 7c 60 7b 24string 7d javascriptstring functions in jsjavascript stringjs stringjs 21 21stringdefine a string jsstring javascrpitstring 28 29 jsjava scripting stringhttps 3a 2f 2f string javascriptstring function in jsjavscript string use string javascriptstring 5b 5d javascriptstring mdn javascriptnew syntax for strings in javascriptin javascript stringcheatsheet javascriptjavascript stringystring in function js 24 javascript string 24 string in javascriptstringy jsstring 28str 29 jsfunctions of string in javascriptjavascript string operations 24 js stringjavascript 2f stringjavascript stringhejs 22 27 stringstring method in javascriptexamples of strings in javascriptfunction for string in jshow to make a string in javascriptjavascript string 24 7b 5d javascript strings w3schoolsmdn javascript stringto string method javascriptjs string 27 22string js mdn 21 21string jsstrings mdn javascriptw3schools stringjs string stringjava scrip strhow to do anything string in javascriptjavascript string 3d 2f string javascriptstrings meaning in javascripthow to use string in jsstring 5b 5d javscriptstring injshow to define string in javascriptin string jsstring javacript 21 21string javascriptdefine string jsfunction from string jsstring js w3cjavascript define string string javascriptmdn stringstring in javascritpjavascript 22string 22 28function 29javascript dom cheat sheet 28pdf 29java script define stringstring javascript functionsjs str function 2bstring javascriptwhat is javascript stringjavascript strings with 60string javascript w3js string functiosnhow can we string in jsnode js strings with syntaxstring methods in javascript mdnjavascript string as textstring in jswork with string in javascriptjavascript stringajs string 22 60 22string javascriptjavascript strings and 5bstring 5d in javascriptstring 3d javascriptstring js functionsstrings in javascript