How to exchange data by javascript
This article mainly explains "javascript how to carry out numerical exchange", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "javascript how to carry out numerical exchange" bar!
The method of numerical exchange of javascript: 1, using intermediate variables for numerical exchange, the syntax "cantileverablea exchange;"; 2, using array exchange for numerical exchange, the syntax "a = [brecrind bacca]".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Now there is a var a = 1 and b = 2, which requires the exchange of an and b values by using javascript, so that a = 2 and b = 1.
1. Intermediate variables (conventional implementation)
Var a = 1, b = 2 var c = a * a = b * b = c *
2. Array exchange (implementation)
Var a = 1, b = 2bot a = [b 2console.log b = a]; console.log (a); / / 2console.log (b); / / Thank you for reading. The above is the content of "how to exchange values in javascript". After the study of this article, I believe you have a deeper understanding of the problem of how to exchange values in javascript, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!