String are used for holding data with quotation mark. There are some method of strings such as:
- Slice — slice is a common method of string, slice helps you extracts a part of a string and return it as a new string. The first parameter is begin Index in which you write the value from where the extraction begins. The second parameter you can write (optional) is end index in which you write the end of extraction.
2. substring — is another method of string that is used to extract the section between start and end index. Start index is used to include the first character that will be returned while end index is used to exclude the first character that will be returned. If start Index is greater than end Index than the arguments will be swapped.
- Trim- trim is a method of string too. It is used to remove whitespaces from both ends of a given string like (space, tab etc)
trimStart( ) removes whitespaces from the start of a string. trimEnd() removes whitespaces from the end of the string.
Numbers is a primitive wrapper object which is used to represent and manipulate numbers.
- Number.isNaN( ) is used to determine the type of number and whether is it a NaN or not.
- Number.toFixed( ) is a method of Number that formats a number using fixed point of series of numbers.
Arrays are list-like objects that has methods which performs alteration operations. The lengths and types of elements in array are not fixed.
- map is a method of array that calls a provided function once for ach element in a array and then creates a new array fitted with it’s result.
2. Slice in arrays is used to return a section of array into a new array by the provided start and end index. Slice will not make any change to the original array.
3.Splice is a method of array which changes the content of it by removing, replacing or adding new elements. It has three parameters first is the start index in which you want to start changing the array, deleteCount is a integer that indicates the number of elements in the array to remove from start. Last is adding items which is optional.
Math is a object which has properties and method which is used for mathematical functions.
- Math.abs( ) is a method of Math that returns the absolute value of a number
- Math.ceil() function always round a number up to the next largest integer.