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

Various properties and methods of the javascript string object, including length, charat, concat, fromcharcode, indexof, slice, and regular expression syntax. Additionally, it covers methods that generate html tags such as big(), bold(), fontcolor(), fontsize(), italics(), small(), strike(), sub(), sup(), and link().

Typology: Study notes

2010/2011

Uploaded on 09/05/2011

nirmalya
nirmalya 🇮🇳

4.5

(2)

17 documents

1 / 70

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JavaScript String
Object
Properties
length - The number of characters in the string.
<script type="text/javascript">
var txt = "Hello World!";
document.write(txt.length);
</script>
OUTPUT 12
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46

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