Docsity

JavaScript String Object: Properties, Methods, and HTML Tags, Study notes of Computer Numerical Control

Partial preview of the text

Download JavaScript String Object: Properties, Methods, and HTML Tags and more Study notes Computer Numerical Control in PDF only on Docsity!

JavaScript String Object Properties length - The number of characters in the string.

OUTPUT 12

1. string.charAt(index) - returns the character at the specified index in a string. - If there is no character at the index, returns an empty string. - The first character is located at index

  1. var place = “Manipal" ; place.charAt(3) ; // ‘i’

3. string .concat(string2, string3, ..., stringX) - is used to join two or more strings. - This method does not change the existing strings, it only returns a copy of the joined strings.

4. String.fromCharCode(n1, n2, ..., nX) - Converts a list of Unicode values into a string containing the corresponding characters. document.write(String.fromCharCode(72,69, 76,76,79)); HELLO document.write(String.fromCharCode(65,66, 67,68,69,97,98,99,100,101));

6. indexOf(pattern, index) :- Returns -1 if the value is not found. Returns the position of the first occurrence of a specified value in a string Searching begins at the index value in the string.

7. lastIndexOf(pattern) - Returns -1 if the value is not found. - Returns the position of the last found occurrence of a specified pattern in a string. 8. lastIndexOf(pattern, index)

  • Returns -1 if the value is not found.
  • Returns the position of the last found occurrence of a specified pattern in a string.
  • Searching begins at the index value in the string and searching towards the beginning of invoking String.

10. substr(start, length) Extracts the characters from a string, beginning at a specified start position, and through the specified number of character

OUTPUT lo world! lo w

11. toLowerCase() - Returns a copy of the string with all characters in lower case. 12. toUpperCase() - Returns a copy of the string with all characters in upper case.

hello world! HELLO WORLD!

Modifi er Description i Perform case-insensitive matching g Perform a global match (find all matches rather than stopping after the first match) [abc] Find any character between the brackets [^abc] Find any character not between the brackets [0-9] Find any digit from 0 to 9 [A-Z] Find any character from uppercase A to uppercase Z [a-z] Find any character from lowercase a to lowercase z [A-z] Find any character from uppercase A to lowercase z [adgk] Find any character in the given set [^adgk] Find any character outside the given set

OUTPUT

6

OUTPUT

OUTPUT Banana,Orange,Apple,Mango splaying array elements by specifing array nam

Methods that generate HTML tags big() - String is displayed in large format. (big tags) document.write("This is BIG text".big()) Is the same as: This is BIG text Producing:

This is BIG text

Methods that generate HTML tags bold() - String is displayed in bold characters. (bold tags) document.write("This is BOLD text".bold()) Is the same as: This is BOLD text Producing: This is BOLD text