Built in functions(methods)
1. alert():
This is used to display a message(dialogue box) on the screen.
eg: alert(“Welcome to JS”);
2. isNaN():
To check whether the given value is a number or not. It returns a Boolean value. If the value is not a number(NaN) then this function returns a true value otherwise it returns a false value.
Eg:
- isNaN(“BVM”); returns true
- isNaN(8172); returns false
- isNaN(“680121”); returns false
- alert(isNaN(8172); displays a message box as false.
3. toUpperCase(): This is used to convert the text to uppercase.
Eg: var x=“bvm”;
alert(x.toUpperCase());
Output is as follows
4. to Lower Case(): This is used to convert the text to lower case.
Eg: var x=“BVM”;
alert(x.toLowerCase());
Output is as follows
5. charAt(): It returns the character at a particular position.
Syntax: variable.charAt(index);
The index of first character is 0 and the second is 1 and so on.
Eg:
var x=”HIGHER SECONDARY”; alert(x.charAt(4));
Output is as follows
Eg 2.
var x=”HIGHER SECONDARY”;
alert(“The characters @ first position is “+ x.charAt(0));
6. length property: It returns the number of characters in a string.
Syntax: variable.length;
Eg.
var x=”HIGHER SECONDARY”;
alert(“The number of characters is “+ x.length);
Output is as follows(note that space is a character)