Exam 8: Manipulating Data in Strings and Arrays
When applied to text strings, the term ____________________ refers to the act of extracting characters or substrings from a larger string.
parsing
Explain the difference between the shift()and unshift()methods of the Array object.
To add elements to or remove elements from the beginning of an array, you need to use the shift( and unshift( methods. The shift( method removes and returns the first element from the beginning of an array, whereas the unshift( method adds one or more elements to the beginning of an array. You append the shift( method to the name of the array whose first element you want to remove. You append the unshift( method to the name of an array and pass to the method a comma-separated list of values for the elements you want to add. For example, the following code declares and initializes an array containing the names of five colors, and then uses the shift( and unshift( methods to change the array contents:
var colors = [ "mauve" , "periwinkle" , "silver" , "cherry" , "lemon" ];
colors.shift(; // colors value now
// ["periwinkle", "silver", "cherry", "lemon"]
colors.unshift( "yellow-orange" , "violet" ;
// colors value now ["yellow-orange", "violet",
// "mauve", "periwinkle", "silver", "cherry", "lemon"]
The shift( method removes the first color, mauve, from the top of the array and the unshift( method adds two new colors, yellow-orange and violet, to the top of the array.
The JavaScript String class includes the ____ method, which creates a new string by combining strings that are passed as arguments.
D
Regular expression patterns consist of literal characters and ____.
You use the ____ method of the String class to split a string into an indexed array.
The ____ method constructs a text string from Unicode character codes that are passed as arguments.
The ____ method of the String class returns the position number in a string of the first character in the argument.
Provide two different regular expressions that return true only when tested against a string consisting of exactly 5 characters.
The ____ object contains methods and properties for working with regular expressions in JavaScript.
The ____ method returns the position number in a string of the first instance of the first character in the pattern argument.
_________________________ are patterns that are used for matching and manipulating strings according to specified rules.
To manipulate arrays in your scripts, you use the methods and length property of the ____ class.
__________ is a data format that represents a JavaScript object as a string.
How can you match any metacharacters as literal values in a regular expression?
To allow a string to contain an alternate set of substrings, you separate the strings in a regular expression pattern with the ____ metacharacter.
The String class ____ property returns the number of characters in a string.
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)