Total WebSite Views Count

JavaScript Important Methods

JavaScript String Methods


MethodDescription
charAt()Returns the character at the specified index (position)
charCodeAt()Returns the Unicode of the character at the specified index
concat()Joins two or more strings, and returns a new joined strings
endsWith()Checks whether a string ends with specified string/characters
fromCharCode()Converts Unicode values to characters
includes()Checks whether a string contains the specified string/characters
indexOf()Returns the position of the first found occurrence of a specified value in a string
lastIndexOf()Returns the position of the last found occurrence of a specified value in a string
localeCompare()Compares two strings in the current locale
match()Searches a string for a match against a regular expression, and returns the matches
repeat()Returns a new string with a specified number of copies of an existing string
replace()Searches a string for a specified value, or a regular expression, and returns a new string where the specified values are replaced
search()Searches a string for a specified value, or regular expression, and returns the position of the match
slice()Extracts a part of a string and returns a new string
split()Splits a string into an array of substrings
startsWith()Checks whether a string begins with specified characters
substr()Extracts the characters from a string, beginning at a specified start position, and through the specified number of character
substring()Extracts the characters from a string, between two specified indices
toLocaleLowerCase()Converts a string to lowercase letters, according to the host's locale
toLocaleUpperCase()Converts a string to uppercase letters, according to the host's locale
toLowerCase()Converts a string to lowercase letters
toString()Returns the value of a String object
toUpperCase()Converts a string to uppercase letters
trim()Removes whitespace from both ends of a string
valueOf()Returns the primitive value of a String object

All string methods return a new value. They do not change the original variable.

Number Methods

MethodDescription
isFinite()Checks whether a value is a finite number
isInteger()Checks whether a value is an integer
isNaN()Checks whether a value is Number.NaN
isSafeInteger()Checks whether a value is a safe integer
toExponential(x)Converts a number into an exponential notation
toFixed(x)Formats a number with x numbers of digits after the decimal point
toLocaleString()Converts a number into a string, based on the locale settings
toPrecision(x)Formats a number to x length
toString()Converts a number to a string
valueOf()Returns the primitive value of a number

JS Array Methods

MethodDescription
concat()Joins two or more arrays, and returns a copy of the joined arrays
copyWithin()Copies array elements within the array, to and from specified positions
entries()Returns a key/value pair Array Iteration Object
every()Checks if every element in an array pass a test
fill()Fill the elements in an arrsay with a static value
filter()Creates a new array with every element in an array that pass a test
find()Returns the value of the first element in an array that pass a test
findIndex()Returns the index of the first element in an array that pass a test
forEach()Calls a function for each array element
from()Creates an array from an object
includes()Check if an array contains the specified element
indexOf()Search the array for an element and returns its position
isArray()Checks whether an object is an array
join()Joins all elements of an array into a string
keys()Returns a Array Iteration Object, containing the keys of the original array
lastIndexOf()Search the array for an element, starting at the end, and returns its position
map()Creates a new array with the result of calling a function for each array element
pop()Removes the last element of an array, and returns that element
push()Adds new elements to the end of an array, and returns the new length
reduce()Reduce the values of an array to a single value (going left-to-right)
reduceRight()Reduce the values of an array to a single value (going right-to-left)
reverse()Reverses the order of the elements in an array
shift()Removes the first element of an array, and returns that element
slice()Selects a part of an array, and returns the new array
some()Checks if any of the elements in an array pass a test
sort()Sorts the elements of an array
splice()Adds/Removes elements from an array
toString()Converts an array to a string, and returns the result
unshift()Adds new elements to the beginning of an array, and returns the new length
valueOf()Returns the primitive value of an array

JS Math Object Methods

MethodDescription
abs(x)Returns the absolute value of x
acos(x)Returns the arccosine of x, in radians
acosh(x)Returns the hyperbolic arccosine of x
asin(x)Returns the arcsine of x, in radians
asinh(x)Returns the hyperbolic arcsine of x
atan(x)Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians
atan2(y, x)Returns the arctangent of the quotient of its arguments
atanh(x)Returns the hyperbolic arctangent of x
cbrt(x)Returns the cubic root of x
ceil(x)Returns x, rounded upwards to the nearest integer
cos(x)Returns the cosine of x (x is in radians)
cosh(x)Returns the hyperbolic cosine of x
exp(x)Returns the value of Ex
floor(x)Returns x, rounded downwards to the nearest integer
log(x)Returns the natural logarithm (base E) of x
max(x, y, z, ..., n)Returns the number with the highest value
min(x, y, z, ..., n)Returns the number with the lowest value
pow(x, y)Returns the value of x to the power of y
random()Returns a random number between 0 and 1
round(x)Rounds x to the nearest integer
sin(x)Returns the sine of x (x is in radians)
sinh(x)Returns the hyperbolic sine of x
sqrt(x)Returns the square root of x
tan(x)Returns the tangent of an angle
tanh(x)Returns the hyperbolic tangent of a number
trunc(x)Returns the integer part of a number (x)

JSON Methods

MethodDescription
parse()Parses a JSON string and returns a JavaScript object
stringify()Convert a JavaScript object to a JSON string

Valid Data Types
In JSON, values must be one of the following data types:
  • a string
  • a number
  • an object (containing valid JSON values)
  • an array
  • a boolean
  • null

JS Date Object Methods


MethodDescription
getDate()Returns the day of the month (from 1-31)
getDay()Returns the day of the week (from 0-6)
getFullYear()Returns the year
getHours()Returns the hour (from 0-23)
getMilliseconds()Returns the milliseconds (from 0-999)
getMinutes()Returns the minutes (from 0-59)
getMonth()Returns the month (from 0-11)
getSeconds()Returns the seconds (from 0-59)
getTime()Returns the number of milliseconds since midnight Jan 1 1970, and a specified date
getTimezoneOffset()Returns the time difference between UTC time and local time, in minutes
getUTCDate()Returns the day of the month, according to universal time (from 1-31)
getUTCDay()Returns the day of the week, according to universal time (from 0-6)
getUTCFullYear()Returns the year, according to universal time
getUTCHours()Returns the hour, according to universal time (from 0-23)
getUTCMilliseconds()Returns the milliseconds, according to universal time (from 0-999)
getUTCMinutes()Returns the minutes, according to universal time (from 0-59)
getUTCMonth()Returns the month, according to universal time (from 0-11)
getUTCSeconds()Returns the seconds, according to universal time (from 0-59)
getYear(). Use the getFullYear() method instead
now()Returns the number of milliseconds since midnight Jan 1, 1970
parse()Parses a date string and returns the number of milliseconds since January 1, 1970
setDate()Sets the day of the month of a date object
setFullYear()Sets the year of a date object
setHours()Sets the hour of a date object
setMilliseconds()Sets the milliseconds of a date object
setMinutes()Set the minutes of a date object
setMonth()Sets the month of a date object
setSeconds()Sets the seconds of a date object
setTime()Sets a date to a specified number of milliseconds after/before January 1, 1970
setUTCDate()Sets the day of the month of a date object, according to universal time
setUTCFullYear()Sets the year of a date object, according to universal time
setUTCHours()Sets the hour of a date object, according to universal time
setUTCMilliseconds()Sets the milliseconds of a date object, according to universal time
setUTCMinutes()Set the minutes of a date object, according to universal time
setUTCMonth()Sets the month of a date object, according to universal time
setUTCSeconds()Set the seconds of a date object, according to universal time
setYear(). Use the setFullYear() method instead
toDateString()Converts the date portion of a Date object into a readable string
toGMTString(). Use the toUTCString() method instead
toISOString()Returns the date as a string, using the ISO standard
toJSON()Returns the date as a string, formatted as a JSON date
toLocaleDateString()Returns the date portion of a Date object as a string, using locale conventions
toLocaleTimeString()Returns the time portion of a Date object as a string, using locale conventions
toLocaleString()Converts a Date object to a string, using locale conventions
toString()Converts a Date object to a string
toTimeString()Converts the time portion of a Date object to a string
toUTCString()Converts a Date object to a string, according to universal time
UTC()Returns the number of milliseconds in a date since midnight of January 1, 1970, according to UTC time
valueOf()Returns the primitive value of a Date object

String HTML Wrapper Methods

The HTML wrapper methods return the string wrapped inside the appropriate HTML tag.

AWS Services

AWS Services

Technology Selection & Evaluation Criteria

Technology Selection & Evaluation Criteria

Scale Cube - Scale In X Y Z Cube

Scale Cube - Scale In X Y Z Cube

Feature Post

AWS Services

About Me

About Me

Spring Cloud

Spring Cloud
Spring Cloud

Spring Cloud +mCloud Native + Big Data Archittect

Spring Cloud +mCloud Native + Big Data Archittect

ACID Transaction

ACID Transaction

Data Pipe Line Stack

Data Pipe Line Stack

Popular Posts