Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function declarations get converted to variable assignment without infinite loop safety #748

Open
EricBalingit opened this issue Apr 27, 2021 · 2 comments

Comments

@EricBalingit
Copy link

variable declaration expressions such as:

var test1 = function ( a, b ) {
    return a + b;
};

result in the expected output with KAInfiniteLoopProtect

while function declarations such as

function test2 ( a, b ) {
    return a + b;
}

do not

repro here:
https://www.khanacademy.org/computer-programming/func-decl-vdecl-without-loop-safety/5771192026742784

@pamelafox
Copy link
Collaborator

Yeah, I'm not surprised that there are issues like that. I added the function syntax for the AP CSP demos, but I don't use them anywhere in Intro to JS since I think there'd also be issues with the coding challenge auto-grader. It would need to be done in a more sophisticated manner than my quick approach. I'll leave this issue open. But generally, I would suggest folks sticks with the var syntax for the best chance of things working.

@lgto4
Copy link

lgto4 commented Feb 25, 2022

I thought it was a feature that I take advantage of all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants