JAVASCRIPT METHODS

Posted by

  1. length // it is a property
  2. toLowerCase()
  3. toUpperCase()
  4. Includes()
  5. startsWith()
  6. endsWith()
  7. search()
  8. match()
  9. indexOf()
  10. lastIndexOf()
  11. replace()
  12. trim()
  13. charAt()
  14. charCodeAt()
  15. fromCharCode()
  16. concat()
  17. Split()
  18. repeat()
  19. slice()
  20. substr()
  21. substring()
  22. toString()
  23. valueOf()
  1. length() //It is a property

Example:-

Output: 30

2. toLowerCase() //Methods are having round brackets

Example:-

Output: javascript is a great language

3. toUpperCase()

Example:

Output: JAVASCRIPT IS A GREAT LANGUAGE

4. includes()

Includes use to find text or word form content . It shows result in true or false.

It is case sensitive method.

Example:

Output: true

5. startsWith()

It returns the first word or character of the sentence

It is a case sensitive method

Example:

Output: true

6. endsWith()

It returns the last word or character of the sentence

It is a case sensitive method

Example:

Output: true

 7.   Search()

It search word and show the index value.

If this method didn’t find anything then it returns -1

Example:

Output: 11

8. match()

It match the word and make it array

Example:

Output: is,is

9. indexOf()

It search position from start and returns index value

Example:

Output: 11

10. lastIndexOf()

It search position of last and returns index value

Example:

Output: 22

11. replace()

It replace the words

Example:

Output: python is a GREAT Language

12. trim()

Example:

Output: JavaScript is a GREAT Language

13. charAt()

It returns the position index value.

Example:

Output: a

14. charCodeAt()

It returns ascii code of given value.

Example:

Output: 97

15. formCharCode()

It shows the ASCII value of given value.

It doesn’t need any string it has inbuilt object

Example:

Output: A

ASCII code table

16. concat()

This function concat or add 2 or more strings.

Example:

Output:

JavaScript is a GREAT Language also python is great language

17. split()

It method use to make  array of string where we put split function

Example:

Output: JavaScript,is,a,GREAT,Language

18. repeat()

It repeat the string as our preference.

Example:

Output: JavaScript is a GREAT LanguageJavaScript is a GREAT Languageuage

19. slice()

It basic use two parameters first character shows for where starts(parameter1) the string with and second parameters shows to the end.

Example:

Output: vaScript is a

20. substr()

It is work similarly as slice but it count value where first parameter is starts.

Example:

Output: vaSc

21. substring()

It is work similarly as substr but it when show parameter2 then it shows less 1 charecter(if we write 5th place it retuns 4th place value)

Example:

Output: vaS

22. toString()

It converts datatype to the string.

Output: 55 (as a string)

23. valueOf()

This function is default, It show string as it is.

Output: JavaScript is a GREAT Language

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x