了解 javascript 语句的使用

understanding the use of javascript statements

这道题不是为了求题解,而是如题所示理解。 我无法对问题进行分类。无需再费周折。我开始在网站上练习Javascript freecodecamp.org.My 主要关注的是freecodecamp.org:

中函数的设置
for ([initialization]; [condition]; [final-expression])

请记住,这三个都是声明。 因此,当我深入挖掘时,网站 w3schools.com 表示:

JavaScript statements are composed of:Values, Operators, Expressions, Keywords, and Comments.

The for loop has the following syntax:
for (statement 1; statement 2; statement 3) {
  // code block to be executed
}

w3schools.com 将字符串显示为语句。 我的问题是: - 这是否意味着对象也可以成为语句? (因为值被认为是语句,所以我指的是名称-值对)。 - 语句和参数如何相互关联? (因为两者都是 'value-holders')

Does that mean Objects can also become statements?

答案是否。

我明白你的意思了:因为你可以在编程语言中使用对象来实现“statement/operator-like意义”,但这些属性只存在于语义中,并不会像实际语句一样成为语法的一部分或语言的运算符。

其实和syntax and semantics when it comes to the inner logic programming languages. I don't want to dig deeper in it because that would be a bit off-topic for Stack Overflow有很大区别,我也不是计算机专业的

Does that mean Objects can also become statements? (Since values are considered to be statements, I am referring to the Name-Value-pairs)

没有。来自 w3schools.com,他们是这样解释声明的:

This statement tells the browser to write "Hello Dolly." inside an HTML element with id="demo": document.getElementById("demo").innerHTML = "Hello Dolly.";

之所以for循环包含三个"statements":

for (statement 1; statement 2; statement 3) {
  // code block to be executed
}

是因为那些语句告诉浏览器做什么:

Statement 1 is executed (one time) before the execution of the code block.

Statement 2 defines the condition for executing the code block.

Statement 3 is executed (every time) after the code block has been executed.


How are statements and parameters connected with each other?

他们不是。

  • 参数在函数中使用,在函数中表现为局部变量;
  • 语句告诉浏览器做什么,并被一一执行

参考文献:

JS Statements

JS for loop

JS Function parameters