Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the method for js to change his own value?

Shulou Source: shulou.com Published: 2022-06-02 22:20:20 10月02日 Update

This article mainly explains "what is the method of js changing self-value". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of js to change your self-value"?

The pop method removes the last element from the array and returns the value of that element.

Var array = ["cat", "dog", "cow", "chicken", "mouse"] var item = array.pop () console.log (array) / / ["cat", "dog", "cow", "chicken"] console.log (item) / / mouse

2. The push method adds one or more elements to the end of the array and returns the new length of the array.

Var array = ["football", "basketball", "badminton"] var I = array.push ("golfball") console.log (array) / / ["football", "basketball", "badminton", "golfball"] console.log (I) / / 4

3. The reverse method reverses the position of the elements in the array and returns the array.

Var array = var array2= array.reverse () console.log (array) / / [5Power4) / / console.log (array2===array) / / true Thank you for your reading. The above is the content of "what is the method for js to change its own value". After the study of this article, I believe you have a deeper understanding of what is the method of js to change your own value. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Methods arrays elements learning content location multiple that is ideas situations articles more end knowledge knowledge points articles follow length questions practice Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Shulou Tech Info NVidia Redmi