Level 46
Level 48
103 words 0 ignored
Ready to learn
Ready to review
Ignore words
Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.
Ignore?
charAt(index)
returns the character at the given index
charCodeAt(index)
returns the Unicode of the character at the specified index
indexOf(value)
returns position of the first found occurrence of value in a string
lastIndexOf(value)
returns the position of the last found occurrence of value in a string
replace(value)
searches a string for value, or a regular expression, and returns a new string where the specified values are replaced
length()
returns length of string
charAt(5)
return char at specified index 5
str.concat(ing)
concatenate string str with string ing
str.indexOf("el")
return position of first found occurrence of "el" in string str
str.lastIndexOf("el")
return position of last found occurrence of "el" in string str
var str = "Visit Microsoft!";
searches string for value/regex, and returns new string where specified values are replaced
str.search("el");
- returns -1 if no match is found
var str = "Hello world!";
extracts part of a string and returns extracted parts
var res = str.split(" ");
return array How, are, you, doing, today?
var res = str.substr(1, 4)
extracts part of a string, beginning at position specified and number of chars specified
var str="Hello world!";
extracts chars from a string, between the two specified indices and returns substring
String.prototype.charAt()
Returns the character at the specified index.
String.prototype.charCodeAt()
Returns a number indicating the Unicode value of the character at the given index.
String.prototype.concat()
Combines the text of two strings and returns a new string.
String.prototype.contains() ECMASCRIPT 6
Determines whether one string may be found within another string.
String.prototype.endsWith() ECMASCRIPT 6
Determines whether a string ends with the characters of another string.
String.prototype.indexOf()
Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
String.prototype.lastIndexOf()
Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
String.prototype.localeCompare()
Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
String.prototype.match()
Used to match a regular expression against a string.
String.prototype.repeat() ECMASCRIPT 6
Returns a string consisting of the elements of the object repeated the given times.
String.prototype.replace()
Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
String.prototype.search()
Executes the search for a match between a regular expression and a specified string.
String.prototype.slice()
Extracts a section of a string and returns a new string.
String.prototype.split()
Splits a String object into an array of strings by separating the string into substrings.
String.prototype.startsWith() ECMASCRIPT 6
Determines whether a string begins with the characters of another string.
String.prototype.substr()
Returns the characters in a string beginning at the specified location through the specified number of characters.
String.prototype.substring()
Returns the characters in a string between two indexes into the string.
String.prototype.toLowerCase()
Returns the calling string value converted to lower case.
String.prototype.toUpperCase()
Returns the calling string value converted to uppercase.
String.prototype.trim()
Trims whitespace from the beginning and end of the string. Part of the ECMAScript 5 standard.
str.concat(str1,str2,...,strx)
Returns a new string that contains the text of the combined strings.
str.search(val)
Returns a number, the position of the first occurrence of the specified searchvalue, or -1 if no match is found
str.slice(start,end)
Returns a string, the extracted part of the string
str.split(separator,limit)
Returns an array containing the splitted values
str.substr(start,length);
Returns a new string containing the extracted part of the text. If length is 0 or negative, an empty string is returned
parseInt('123',10)
Turn a String '123' to an Integer.
isNaN(str)
Returns a boolean. Check if it is not a number.
str.charCodeAt()
Returns the Unicode of the character at the specified index
str.indexOf()
Returns the position of the first found occurrence of a specified value in a string
str.lastIndexOf()
Returns the position of the last found occurrence of a specified value in a string
str.match()
Searches for a match between a regular expression and a string, and returns the matches
str.replace()
Searches for a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring
str.valueOf()
Returns the primitive value of a String object
repeat()
constructs and returns a new string which contains the specified number of copies of the string on which it was called, concatenated togethe
charAt
The charAt() method returns the specified character from a string.
indexOf
The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.
split
The split() method splits a String object into an array of strings by separating the string into substrings.
lastIndexOf
The lastIndexOf() method returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. The calling string is searched backward, starting at fromIndex.
replace
The replace() method returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a st…
slice
The slice() method extracts a section of a string and returns a new string.
substr
The substr() method returns the characters in a string beginning at the specified location through the specified number of characters. (Chris prefers slice())
substring
The substring() method returns a subset of a string between one index and another, or through the end of the string.
toLowerCase
The toLowerCase() method returns the calling string value converted to lowercase.
toUpperCase
The toUpperCase() method returns the calling string value converted to uppercase.
trim
The trim() method removes whitespace from both ends of a string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
sub()
Display the string as subscript text.
Array.prototype.join()
Joins all elements of an array into a string.
Array.prototype.length
An unsigned, 32-bit integer that specifies the number of elements in an array.
Array.prototype.pop()
Removes the last element from an array and returns that element.
Array.prototype.push()
Adds one or more elements to the end of an array and returns the new length of the array.
Array.prototype.reverse()
Reverses an array in place. The first array element becomes the last and the last becomes the first.
Array.prototype.shift()
Removes the first element from an array and returns that element. This method changes the length of the array.
Array.prototype.unshift()
Adds one or more elements to the beginning of an array and returns the new length of the array.
Array.prototype.splice()
Changes the content of an array, adding new elements while removing old elements.
Object.keys()
Returns an array of a given object's own enumerable properties, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).
Constructor, Length, Prototype
Properties of the string object
Constructor
A function that is written with the new keyword to initialize a newly created object
length
array property that sets or returns the number of elements in an array
prototype
Allows you to add properties and methods to an Array object
What is the difference between substr() and substring()?
substr() -- you specifiy the beginning index position and the number of characters you want to extract. substring() -- you specify the beginning index position AND the ending index position.
36
var n = str.lastIndexOf("planet");
DOM node children
myNode.children (elements only)
myNode.parentNode
DOM node parent
DOM node classes (2)
myNode.className (string of all classes)
myNode.attributes
get DOM node attributes
arr.splice(index, 0, 'x')
Insert a value in place in an array
arr.splice(1, 2)
Remove 2 values from an array, starting at the 2nd item
document.querySelector
Get a single DOM node
document.querySelectorAll('.link')
Get all DOM nodes that match a selector
document.getElementsByTagName('*')
Get all DOM nodes, period
document.body.querySelectorAll( '*' )
Get all DOM nodes inside the body tag
arr = Array.prototype.slice.call(nodeList)
Convert an array-like object to an array
[].indexOf.call(node.parentNode.children, node)
Get DOM node index among siblings
fileName.slice(0, -4)
Remove the last 4 chars from a string
node.childElementCount
Direct way to count DOM node children
arr.sort()
Sort an array of strings
Sort an array of numbers
arr.sort(function(a,b){ return a - b; })
Strings are objects and therefore have properties like
var phrase = "This is a simple phrase";
Since strings are object, they have methods
var phrase = "This is a simple phrase";
var phrase = "This is a simple phrase";
Split Method using a 'space' for a calling argument...
var phrase = "We want a groovy keyword.";
indexOf method using a 'word' for a calling argument...
lastIndexOf method
console.log( phrase.lastIndexOf() );
phrase.slice method
var phrase = "Yet another phrase.";
sub string method
.substring(start, end)
string comparison
var str1 = "Hello";
String comparison uppercase is less than lower case
var str1 = "aardvark"; var str2 = "Bluga";
0
The exception (err) is caught by the catch statement and a custom error message is displayed: