Forms Version 12.0.2509.20409 Layout Designer.
After an hour or so trying to figure out why my Javascript was not working as expected, it finally dawned on me the issue is based on the way that the Preview works.
On the Preview, you can select which step/task you want to use for previewing the form, and this is great. But what isn't apparent with this is that your Javascript isn't re-run when you change which step/task you are viewing.
So if you have some Javascript that is step/task dependent (using properties like LFForm.step.name) that Javascript is loaded when the Preview first loads, prior to selecting the step/task from the drop-down. And it isn't reloaded when you change the step/task. You can't use the browser to refresh the page as that just starts the preview all over. As far as I can see, you can't tell it to re-run your Javascript on the new step/task.
This means that your code that is step/task dependent isn't going to work like you expect (unless you have it triggered by user action, like a button - or some other event).
I don't know if there is any workaround for this, and it's probably only an issue for 0.001% of situations, so this post is mostly about saying:
Did you realize it worked this way? Maybe now that you know you can avoid that frustration of spending way too long trying to find a bug in your code that isn't actually a bug, but just a difference in how the Preview works versus an actual run of the step/task.