简体   繁体   English

你好:“世界”为什么这是有效的JavaScript?

[英]hello : “world” How come this is valid javascript?

I was messing around in console when I typed in echo : "test" and to my suprised the string "test" was returned to console. 当我输入echo : "test"时,我在控制台中echo : "test" ,令我惊讶的是字符串“test”返回到控制台。

How come this is valid syntax without a ? 为什么这是没有的有效语法? in a (boolean) ? trueresult : falseresult (boolean) ? trueresult : falseresult (boolean) ? trueresult : falseresult

Are there possible uses except a fancy way to mess in console? 有没有可能的用途,除了一种奇怪的方式来搞乱控制台?

In this case echo: is creating a label. 在这种情况下, echo:正在创建一个标签。

See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label 请参阅: https//developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label

The echo: is creating the label and hence the output echo:正在创建标签 ,从而创建输出

Description 描述

You can use a label to identify a loop, and then use the break or continue statements to indicate whether a program should interrupt the loop or continue its execution. 您可以使用标签来标识循环,然后使用break或continue语句来指示程序是应该中断循环还是继续执行。

Note that JavaScript has NO goto statement, you can only use labels with break or continue. 请注意,JavaScript没有goto语句,您只能使用带有break或continue的标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM