Javascript String Object Tutorial
Javascript String Object Tutorial
Javascript String Object Tutorial
The String object is used to manipulate a stored piece of text. String objects are created with new String().
Syntax
var txt = new String("string"); or more simply: var txt = "string"; For a tutorial about the String object, read our JavaScript String Object tutorial.
the position of the match Extracts a part of a string and returns a new string Splits a string into an array of substrings Extracts the characters from a string, beginning at a specified start position, and through the specified number of character Extracts the characters from a string, between two specified indices Converts a string to lowercase letters Converts a string to uppercase letters Returns the primitive value of a String object
Date Object
The Date object is used to work with dates and times.
Date objects are created with new Date(). There are four ways of instantiating a date:
var d = new Date(); var d = new Date(milliseconds); var d = new Date(dateString); var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
For a tutorial about date and times, read our JavaScript Date Object tutorial.
getTimezoneOffset() getUTCDate() getUTCDay() getUTCFullYear() getUTCHours() getUTCMilliseconds() getUTCMinutes() getUTCMonth() getUTCSeconds() getYear() parse() setDate() setFullYear() setHours() setMilliseconds() setMinutes() setMonth() setSeconds() setTime() setUTCDate() setUTCFullYear()
Returns the time difference between UTC time and local time, in minutes Returns the day of the month, according to universal time (from 1-31) Returns the day of the week, according to universal time (from 0-6) Returns the year, according to universal time (four digits) Returns the hour, according to universal time (from 0-23) Returns the milliseconds, according to universal time (from 0-999) Returns the minutes, according to universal time (from 0-59) Returns the month, according to universal time (from 0-11) Returns the seconds, according to universal time (from 0-59) Deprecated. Use the getFullYear() method instead Parses a date string and returns the number of milliseconds since midnight of January 1, 1970 Sets the day of the month of a date object Sets the year (four digits) of a date object Sets the hour of a date object Sets the milliseconds of a date object Set the minutes of a date object Sets the month of a date object Sets the seconds of a date object Sets a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970 Sets the day of the month of a date object, according to universal time Sets the year of a date object, according to universal time (four digits)
setUTCHours() setUTCMilliseconds() setUTCMinutes() setUTCMonth() setUTCSeconds() setYear() toDateString() toGMTString() toISOString() toJSON() toLocaleDateString() toLocaleTimeString() toLocaleString() toString() toTimeString() toUTCString() UTC() valueOf()
Sets the hour of a date object, according to universal time Sets the milliseconds of a date object, according to universal time Set the minutes of a date object, according to universal time Sets the month of a date object, according to universal time Set the seconds of a date object, according to universal time Deprecated. Use the setFullYear() method instead Converts the date portion of a Date object into a readable string Deprecated. Use the toUTCString() method instead Returns the date as a string, using the ISO standard Returns the date as a string, formated as a JSON date Returns the date portion of a Date object as a string, using locale conventions Returns the time portion of a Date object as a string, using locale conventions Converts a Date object to a string, using locale conventions Converts a Date object to a string Converts the time portion of a Date object to a string Converts a Date object to a string, according to universal time Returns the number of milliseconds in a date string since midnight of January 1, 1970, according to universal time Returns the primitive value of a Date object
Array Object
The Array object is used to store multiple values in a single variable.
For a tutorial about Arrays, read our JavaScript Array Object tutorial.
unshift() valueOf()
Adds new elements to the beginning of an array, and returns the new length Returns the primitive value of an array
Boolean Object
The Boolean object is used to convert a non-Boolean value to a Boolean value (true or false). For a tutorial about the Boolean object, read our JavaScript Boolean Object tutorial.
Math Object
The Math object allows you to perform mathematical tasks. Math is not a constructor. All properties/methods of
Syntax
var x = Math.PI; // Returns PI var y = Math.sqrt(16); // Returns the square root of 16
For a tutorial about the Math object, read our JavaScript Math Object tutorial.
LN2
LN10
LOG2E
1.442) Returns the base-10 LOG10E logarithm of E (approx. 0.434) PI Returns PI (approx. 3.14)
Returns the square root of SQRT1_2 1/2 (approx. 0.707) Returns the square root of 2 (approx. 1.414)
SQRT2
abs(x)
acos(x)
asin(x)
atan(x)
numeric value between PI/2 and PI/2 radians Returns the arctangent of the quotient of its arguments Returns x, rounded upwards to the nearest integer Returns the cosine of x (x is in radians) Returns the value of Ex Returns x, rounded downwards to the nearest integer Returns the natural logarithm (base E) of x
atan2(y,x)
ceil(x)
cos(x)
exp(x)
floor(x)
log(x)
Returns the number max(x,y,z,...,n) with the highest value Returns the number min(x,y,z,...,n) with the lowest value Returns the value of x to the power of y Returns a random number between 0 and 1 Rounds x to the nearest integer Returns the sine of x (x is in radians) Returns the square root of x Returns the tangent of an angle
pow(x,y)
random()
round(x)
sin(x)
sqrt(x)
tan(x)