TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: NodeScript- JavaScript Without the Variable Declarations and Semicolons

5 点作者 pretodor超过 8 年前

2 条评论

rco8786超过 8 年前
Interesting. It&#x27;s worth noting that semicolons are generally optional in javascript, and there&#x27;s a growing contingency of folks who actively do not use them and rely on their build tools to inject where necessary. Sounds like it would lead to subtle bugs but I guess it works ok.<p>Anyway, nice work in general! Assuming this only works with &#x27;let&#x27; to avoid the weirdness around &#x27;var&#x27; scoping?
评论 #13688550 未加载
评论 #13689132 未加载
评论 #13701543 未加载
clusmore超过 8 年前
How does this handle shadowing? Consider, for example,<p><pre><code> let x = 1; function foo() { let x = 2; } function bar() { x = 3; } console.log(x); &#x2F;&#x2F; 1 foo(); console.log(x); &#x2F;&#x2F; 1 bar(); console.log(x); &#x2F;&#x2F; 3 </code></pre> Without the declaration, how can you tell whether I intend to shadow or not?<p>Edit: I note from another comment that you state<p>&gt; If you want to make a global variable, you will have to explicitly write it as a property of the global object.<p>The example above could appear in any scope, not only the global scope. Python now has a `nonlocal` keyword (as well as the `global` keyword) to disambiguate these cases.
评论 #13694346 未加载