JAVA SCRIPT DAY 14 (The Number Object, The Boolean Object, The Strings Object, String HTML Wrappers )

DAY - 14
JavaScript - The Number Object
Ø   The Number object represents numerical date, either integers or floating-point numbers.
Ø   In general, you do not need to worry about Number objects because the browser automatically converts number literals to instances of the number class.
Ø   The syntax for creating a number object is as follows −
varval=newNumber(number);
Ø  In the place of number, if you provide any non-number argument, then the argument cannot be converted into a number, it returns NaN (Not-a-Number).

 

Number Properties

Ø  The following is a list of each property and their description.
Property
Description
The largest possible value a number in JavaScript can have 1.7976931348623157E+308
The smallest possible value a number in JavaScript can have 5E-324
Equal to a value that is not a number.
A value that is less than MIN_VALUE.
A value that is greater than MAX_VALUE
A static property of the Number object. Use the prototype property to assign new properties and methods to the Number object in the current document
Returns the function that created this object's instance. By default this is the Number object.

 

Number Methods

Ø   The Number object contains only the default methods that are a part of every object's definition.
Method
Description
Forces a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation.
Formats a number with a specific number of digits to the right of the decimal.
Returns a string value version of the current number in a format that may vary according to a browser's local settings.
Defines how many total digits (including digits to the left and right of the decimal) to display of a number.
Returns the string representation of the number's value.
Returns the number's value.






JavaScript - The Boolean Object

Ø   The Boolean object represents two values, either "true" or "false". If valueparameter is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (""), the object has an initial value of false.
Ø   The syntax to create a boolean object is
varval=newBoolean(value);

 

Boolean Properties

Ø   The list of the properties of Boolean object are−
Property
Description
Returns a reference to the Boolean function that created the object.
The prototype property allows you to add properties and methods to an object.

 

Boolean Methods

Ø    The list of methods of Boolean object and their description are:-
Method
Description
Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
Returns a string of either "true" or "false" depending upon the value of the object.
Returns the primitive value of the Boolean object.






The Strings Object

Ø The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods.
Ø As JavaScript automatically converts between string primitives and String objects, you can call any of the helper methods of the String object on a string primitive.
Ø Use the following syntax to create a String object −
varval=newString(string);
Ø The String parameter is a series of characters that has been properly encoded.

 

String Properties

Ø The following is the list of the properties of String object and their description.
Property
Description
Returns a reference to the String function that created the object.
Returns the length of the string.
The prototype property allows you to add properties and methods to an object.

 

String Methods

Ø The following is the list of methods available in String object along with their description.
Method
Description
Returns the character at the specified index.
Returns a number indicating the Unicode value of the character at the given index.
Combines the text of two strings and returns a new string.
Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
Returns a number indicating whether a reference string comes before or after or is the same as the given string in sort order.
Used to match a regular expression against a string.
Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
Executes the search for a match between a regular expression and a specified string.
Extracts a section of a string and returns a new string.
Splits a String object into an array of strings by separating the string into substrings.
Returns the characters in a string beginning at the specified location through the specified number of characters.
Returns the characters in a string between two indexes into the string.
The characters within a string are converted to lower case while respecting the current locale.
The characters within a string are converted to upper case while respecting the current locale.
Returns the calling string value converted to lower case.
Returns a string representing the specified object.
Returns the calling string value converted to uppercase.
Returns the primitive value of the specified object.

 

String HTML Wrappers

 

Ø  The following is the list of methods that return a copy of the string wrapped inside an appropriate HTML tag.
Method
Description
Creates an HTML anchor that is used as a hypertext target.
Creates a string to be displayed in a big font as if it were in a <big> tag.
Creates a string to blink as if it were in a <blink> tag.
Creates a string to be displayed as bold as if it were in a <b> tag.
Causes a string to be displayed in fixed-pitch font as if it were in a <tt> tag
Causes a string to be displayed in the specified color as if it were in a <font color="color"> tag.
Causes a string to be displayed in the specified font size as if it were in a <font size="size"> tag.
Causes a string to be italic, as if it were in an <i> tag.
Creates an HTML hypertext link that requests another URL.
Causes a string to be displayed in a small font, as if it were in a <small> tag.
Causes a string to be displayed as struck-out text, as if it were in a <strike> tag.
Causes a string to be displayed as a subscript, as if it were in a <sub> tag
Causes a string to be displayed as a superscript, as if it were in a <sup> tag

No comments:

Post a Comment

Give your valuable feedback

Topic :Software & Types, Subject: Computer Fundamental Notes for CSJM University Kanpur(for different courses like BBA, BCA, etc..)

Software Software refers to the programs, data, and instructions that enable a computer or other digital device to perform specific tasks or...