· Object (Function, Array, Date, RegExp)
Number(value) converts any string value to Number and if there is no number inside the string or it cannot be converted it will return NaN example:
const num = Number('123')console.log(num)
Number function has different valuable methods here are some important methods are given below.
· trim and more….
1. String.charAt( )
This string return new string consisting of single 16-bit code unit. Here is a example
2. String.indexOf( )
This method return index value of calling string object with its present specified values. And if it does not found any value it will return -1 value.
const line = 'Most valuable and wonderful programming language';const indexOf = line.indexOf('valuable');console.log(indexOf);
3. String.lastIndexOf( )
This method return the index value of calling string object of the last inserted value from the line and it searches its value from backward. If does not found any value it will return -1 value.
4. String.slice( )
This method extracts a string section from the line which we defined in the code then it provides another new string without changing the original string code.
const line = 'Most valuable and wonderful programming language';console.log(line.slice(18));
5. String.replace( )
Replace method helps to replace a new string with another old string from the line. Actually, it will not change the full string original string will be unchanged.
const line = 'Most valuable and wonderful programming language';console.log(line.replace('wonderful', 'effective'));
6. String.split( )
This method helps to divide the actual string into substrings then keep those substrings into an array and return them.
const line = 'Most valuable and wonderful programming language';const words = line.split(' ');console.log(words);const chars = line.split('');console.log(chars);
· slice and more.
1. Array.concat( ):
Concat method helps to merge two, three more arrays into one array. Existing array remain unchanged but it completely return new merged array. Example:
const array1 = ['1', '2', '3'];const array2 = ['4', '5', '6'];const array3 = array1.concat(array2);console.log(array3);
2. Array.pop( )
if you have really long array and you want remove last element from that array this pop method will help to remove. Example:
const friends = ['karim', 'rahim', 'kader', 'kamel', 'jamal'];console.log(friends.pop());console.log(friends);
3. Array.push( )
This is the alternative of pop method it will add new elemant end of the array so here is nothing to understand about this array. Example:
const friends = ['karim', 'rahim', 'kader', 'kamel'];console.log(friends.push('jamal'));console.log(friends);
· Math.abs( )
· Math.floor( )
· Math.ceil( )
· Math.max( )
· Math.random( )
· Math.round( ) and more.
1. Math.floor( )
This is very useful math property. This function returns given integers less number or equal number. Example:
2. Math.ceil( )
This is also opposite of math.floor because it returns given integers largest number. For example: