JS学习-2个变量进行交换案例_javascript

 

手写的 字比较飘 别介意

 

代码:

        <script type="text/javascript">
            var temp;
            var apple1='青苹果';
            var apple2='红苹果';
            temp=apple1;
            apple1=apple2;
            apple2=temp;
            console.log(apple1);
            console.log(apple2);
        </script>