
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
37 lines
630 B
Plaintext
37 lines
630 B
Plaintext
== Why is this an issue?
|
|
|
|
While most script engines support function declarations within blocks, from browser to browser, the implementations are inconsistent with each other.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
if (x) {
|
|
function foo() {} //foo is hoisted in Chrome, Firefox and Safari, but not in Edge.
|
|
}
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
if (x) {
|
|
const foo = function() {}
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Do not use function declarations within blocks.
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|