Pabel Yeatun
3 min readMay 5, 2021

--

JavaScript (JS) may be a lightweight, deciphered, or just-in-time compiled programming dialect with first-class capacities. Whereas it is most well-known as the scripting dialect for Web pages

Now I am discussion most top 10 method while using java script

1)String.prototype.concat():

The concat() strategy concatenates the string contentions to the calling string and returns a modern string. Here is example:

const str1 = ‘Hi’;

const str2 = ‘Guys’;

console.log(str1.concat(‘ ‘, str2)); // output: “Hello guys”

console.log(str2.concat(‘, ‘, str1)); // output: “Guys, Hi”

For this the language structure are utilized concat(str1) concat(str1, str2) concat(str1, str2, … , strN) The concat() work concatenates the string contentions to the calling string and returns a modern string. Changes to the first string or the returned string do not influence the other. If the contentions are not of the sort string, they are changed over to string values some time recently concatenating

2)String.prototype.indexOf() :

The indexOf() strategy returns the file inside the calling String protest of the primary event of the required esteem, beginning the search at fromIndex. Returns -1 in case the esteem isn’t found.

here is the syntax :

indexOf(searchValue)

indexOf(searchValue, fromIndex)

3)String.prototype.lastIndexOf():

The lastIndexOf() strategy returns the record inside the calling String protest of the final event of the required esteem, looking in reverse from fromIndex. Returns -1 in case the esteem isn’t found.

syntax is

lastIndexOf(searchValue)

lastIndexOf(searchValue, fromIndex)

4)String.prototype.slice()

The slice() strategy extricates a segment of a string and returns it as a modern string, without adjusting the original string.

Syntax:

slice(beginIndex)
slice(beginIndex, endIndex)

Description

slice() extracts the content from one string and returns a modern string. Changes to the content in one string don’t influence the other string.

slice() extricates up to but not counting endIndex. str.slice(1, 4) extricates the moment character through the fourth character (characters recorded 1, 2, and 3). As an case, str.slice(2, -1) extricates the third character through the moment to last character within the string

5)Number.isNaN()

The Number.isNaN() strategy decides whether the passed esteem is NaN and its sort is Number. It could be a more strong adaptation of the initial, worldwide isNaN().

Syntax
Number.isNaN(value)

6)The Number.parseFloat():

The Number.parseFloat() strategy parses an contention and returns a coasting point number. In case a number cannot be parsed from the contention, it returns NaN.

syntax:

Number.parseFloat(string)

7)The Math.floor():

The Math.floor() work returns the biggest numbers less than or break even with to a given number.

floor() may be a inactive strategy of Math, you continuously utilize it as Math.floor(), instead of as a strategy of a Math object you made (Math isn’t a constructor)

8)Array.prototype.find():

The find() strategy returns the esteem of the primary component within the given cluster that fulfills the given testing function. On the off chance that no values fulfill the testing function, undefined is returned.

If you would like to find the index of a value, use Array.prototype.indexOf().

If you wish to find on the off chance that a esteem exists in an cluster, utilize Array.prototype.includes().

Once more, it checks each component for correspondence with the esteem rather than employing a testing function.

If you would like to find in case any element satisfies the provided testing function, utilize Array.prototype.some()

9)Array.prototype.pop()

The pop() strategy evacuates the final component from an array and returns that element. This strategy changes the length of the array.

syntax

pop();

pop is intentioned non specific; this strategy can be called or connected to objects resembling arrays. Objects which don’t contain a length property reflecting the final in a arrangement of sequential, zero-based numerical properties may not carry on in any significant manner.

10)Array.prototype.push()

The push() strategy includes one or more elements to the end of an array and returns the modern length of the array.

syntax:

push(element0)
push(element0, element1)
push(element0, element1, ... , elementN)

push is intentionally generic. This method can be utilized with call() or apply() on objects taking after arrays. The thrust method depends on a length property to decide where to begin embeddings the given values. In case the length property cannot be changed over into a number, the record utilized is 0. This incorporates the plausibility of length being nonexistent, in which case length will too be created.

--

--