30 lines
524 B
Plaintext
30 lines
524 B
Plaintext
While most script engines support function declarations within blocks, from browser to browser, the implementations are inconsistent with each other.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
if (x) {
|
|
function foo() {} //foo is hoisted in Chrome, Firefox and Safari, but not in Edge.
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
if (x) {
|
|
const foo = function() {}
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|