Difference between expressions and statements?

  1. 表达式返回的是值,可以直接打印出来;
5 + 5 // => 10

lastCharacter("input") // => "t"

true === true // => true
  1. 语句是执行的某种操作
let x = 0

function declaration() {}

if (true) {
}
  1. Expression statement: produces a value and performs an action
// Assign `x` as the absolute value of `y`.
var x = y >= 0 ? y : -y

猜你喜欢

转载自blog.csdn.net/wml00000/article/details/88545715