Sourav Mandal
Sourav Mandal

@souravcode

10 Tweets 1 reads Oct 15, 2022
🟒 Operations On Array in JavaScript!
A thread...⇩
βœ… we use some methods of JavaScript for array Operations!
βœ” here some methods are!
➊ push
βž‹ length
➌ unshift
➍ pop
➎ shift
➏ splice
➐ Array.isArray
➊ push
➟ The "push" method Add a new item to an array.
for example ⇩
βœ” ["computer science", "math", "bio", "physics"]; ➟ this is an array & stores some methods but if you want to add a new (element) to this array use the "push" method.
βž‹ length
➟ The "length" method of arrays in JavaScript. that returns the number of elements in a given array.
➌ unshift
➟ The "unshift" method adds new elements or 'items' to the beginning of an array.
➀ For example, you have created an array & store some elements & you want to add new elements from the beginning of this array.
➍ pop
➟ The "pop" method is used to remove elements.
➀ For example ["CS", "Math", "Bio"] This is an array & stores 3 elements if you want to remove the last element in this array use the "pop" property.
➎ shift
➟The "shift" method works exactly same as the "pop" property but the Difference is only that the "pop" remove the last elements & the "shift" remove the first element in an array.
➏ splice
let book = ["CS", "Math", "Bio"]; (this is a array)
➟The splice() method removes a particular element in an array.
You can use the splice() method to remove the book names from the 'book'!
➐ Array.isArray
➟ The Array.isArray() method determines whether the passed value is an Array.
For example, if you have created an array or variable & you want to check if it is an array or not you can use this Array.isArray() method.
That's it for this thread. If you found it useful!
🀝 Follow me
@souravcode
Hey, I am a Web Developer From India, Helping people learn web development. I Tweet Around.
HTML
CSS
JavaScript
React, & More Tips & Web Development Content.
Like πŸ’–
Retweet

Loading suggestions...