Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • 10
    \$\begingroup\$ That clear function seems to be a SpiderMonkey-shell-specific addition, not a generic JavaScript thing. It certainly doesn't appear in the ES5 spec § Function Properties of the Global Object. I tried this with node and got a "ReferenceError: clear is not defined". In Chrome's and Firefox's console, the clear function just clears the console, regardless of what arguments it is passed. Or perhaps the tool you used complied to a version of ECMAScript older than 5.1? \$\endgroup\$
    – Anko
    Commented Jan 22, 2016 at 1:01
  • 5
    \$\begingroup\$ Could you instead amend the statement “Isn't it nice how JavaScript has such a nice function to destroy itself”? JavaScript doesn't have that function, only the SpiderMonkey implementation does. \$\endgroup\$
    – Anko
    Commented Jan 22, 2016 at 1:12
  • 12
    \$\begingroup\$ I think you're confusing JavaScript (the language) with SpiderMonkey (one of the many implementations of the language). Extreme allegory: While I could write a crazy implementation of C in which all invocations of undefined behaviour result in printing the full text of the Declaration of Human Rights, I probably wouldn't be able to argue that my C submission to "golf the UDHR" that just dereferences a null pointer is a valid C solution. :) \$\endgroup\$
    – Anko
    Commented Jan 22, 2016 at 1:42
  • 16
    \$\begingroup\$ @Anko As a per site rule, a language is defined by its implementation. If an answer works consistently in at least one implementation that was published before the question, then it is acceptable. See here and here. (So the code is valid. But I'll not comment on that specific wording.) \$\endgroup\$
    – jimmy23013
    Commented Feb 23, 2016 at 1:21
  • 2
    \$\begingroup\$ Can you write the Node.js version as you promised now? \$\endgroup\$ Commented Jun 16, 2020 at 20:59