Hoisting?

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Hi, I’m just wondering why javascript hoisting does not apply in the following example? I placed the variable declaration below the function and received an error message stating that $target is undefined.

Isn’t the declaration supposed to be ‘hoisted’ to the top?

```

$(document).ready(function() {
$target.fadeOut(‘fast’);
var target = ("#jq")
});

<do not remove the three backticks above>

you first specify you want to fadeOut $target, then you specify what $target is. That doesn’t work.

i can’t fadeOut a target if i don’t know what the target is, and neither can the computer

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.