Suhail Kakar Profile picture
dev @livepeer β€’ building decentralized social media @onboard_hq β€’ helping developers break into ai and web3 β€’

Nov 16, 2021, 31 tweets

25+ JavaScript Methods Explained 🀯

- Strings
- Objects
- Numbers
- Arrays

A mega-thread 🧡

πŸ’  String

A JavaScript string stores a series of characters or a string is a collection of characters. A string can be any text inside double or single quotes.

String Methods πŸ‘‡

βœ… toUpperCase()

The toUpperCase method is used to convert a string to upper case.

βœ… toLowerCase()

The to Lowercase is used to convert a string to lower case.

βœ… slice()

This method is used to return the sliced part of a string, it takes one or two arguments that indicate the initial and end of the slice. The arguments can also be negative.

βœ… substr()

This method is similar to slice, however, the second parameter indicates the length of the part that should be extracted.

βœ… replace()

The replace method is used to replace a part of a string with another string. This method is case-sensitive.

βœ… concat()

This method is used to concatenate two or more strings.

βœ… trim()

This method is used to remove the spaces from both sides of the string.

βœ… charCodeAt

The charCodeAt returns the unicode of the character at a specified index in a string.

βœ… charAt()

This method returns the character of a specific index in a string.

βœ… padStart

This method is used to add padding at the starting of a string.

βœ… padEnd

It adds padding at the end of the string.

βœ… length

This method is used to return the length of a string.

πŸ’  Objects

The Object is the JavaScript data type. It is used to store various keyed collections and each key can have a value.

Object Methods πŸ‘‡

βœ… keys()

This method returns the keys of an object.

βœ… values()

This method returns the values of an object.

βœ… create()

This method is used to create a new object from the existing object.

βœ… freeze()

The Object.freeze() method freezes an object. This method will allow an object to be changed, freezing an object prevents changing, for example, adding new properties to it, removing existing properties from it.

βœ… assign()

This method is used to copy the properties of one object to another object.

πŸ’  Numbers

The number is the numeric data type of Javascript that stores normal integer, floating-point values.

Numbers methods πŸ‘‡

βœ… toFixed()

This method writes the number with a specified number of decimals and returns its value as a string.

βœ… parseFloat()

This method converts the function argument to a string first and returns a floating-point number.

βœ…Number()

This method is used to convert the value of other data types to numbers.

βœ… parseInt()

This method converts the function argument to a string first and returns an integer.

πŸ’  Array

Array is a single variable that store a list of values and each element is specified by a single index.

Array Methods πŸ‘‡

βœ… pop()

The pop() method removes the last element of an array.

βœ… shift()

The shift() method removes the first element from an array.

βœ… push()

The push() method adds one or more elements to the end of an array.

βœ… length

The length returns the number of elements in an array.

That is it :D

If you found this thread useful, consider:

βœ… Following me @SuhailKakar for more content like this
πŸ”„ Retweeting the first tweet.

Thanks for your support πŸ™Œ

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling