1.运算不同
- n++ 后执行自增运算
- ++n 先执行自增运算
2.内存不同
- n++ 先访问参数n,之后将参数n加1
- ++n 先将参数n加1,之后再访问参数n
3. 代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var n = 1;
console.log(n++); /