Eloquent-JavaScript icon indicating copy to clipboard operation
Eloquent-JavaScript copied to clipboard

Error in the sandbox, not present in other environments (ex #15.2)

Open bitwkit opened this issue 7 years ago • 5 comments

The solution I made for the exercise 15.2 is working fine in JSFiddle, Codepen and as a local html file in browser (Chrome 65.0.3325.181), but produses the following error when being run in the sandbox: "TypeError: Cannot read property 'style' of undefined (line 26)"

Code: exercise 15.2

bitwkit avatar Jun 05 '19 12:06 bitwkit

Ah, you're using an obscure feature in setTimeout that isn't supported by the overridden version in the sandbox. Attached patch should fix that.

marijnh avatar Jun 05 '19 12:06 marijnh

(Also, you can just access charNode from inside the function you pass to setTimeout, so you don't need to pass it as an extra argument through setTimeout)

marijnh avatar Jun 05 '19 12:06 marijnh

(Also, you can just access charNode from inside the function you pass to setTimeout, so you don't need to pass it as an extra argument through setTimeout) Is this because of clojure? ...and if this is an "obscure" feature of setTimeout, does it mean it is not recommended to use?

bitwkit avatar Jun 05 '19 13:06 bitwkit

Is this because of clojure?

Yes (though Clojure is a Lisp dialect, and the feature is called closure)

...and if this is an "obscure" feature of setTimeout, does it mean it is not recommended to use?

It's standard, and it should work fine—I just wasn't aware of it when I wrote the placeholder.

marijnh avatar Jun 05 '19 13:06 marijnh

Thanks a lot! And thank you very much for the book!

bitwkit avatar Jun 05 '19 13:06 bitwkit