Does JavaScript ignore the remaining lines of code in a function after it makes a recursive call?How to turn a String into a JavaScript function call?What does the function then() mean in JavaScript?Android Calling JavaScript functions in WebViewCalling a javascript function recursivelyWhy does JavaScript only work after opening developer tools in IE once?Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for itcheck for alpha only colors using javascriptWhy is my variable unaltered after I modify it inside of a function? - Asynchronous code referenceJavascript - unexpected result checking variable assignmentUnable to generate multiple Images
Why does the seven segment display have decimal point at the right?
My Friend James
Are there mathematical concepts that exist in the fourth dimension, but not in the third dimension?
How do English-speaking kids loudly request something?
Remaining in the US beyond VWP admission period
Was "The Hobbit" ever abridged?
Why would one hemisphere of a planet be very mountainous while the other is flat?
If I have an accident, should I file a claim with my car insurance company?
Can taking my 1-week-old on a 6-7 hours journey in the car lead to medical complications?
First Number to Contain Each Letter
Looking for the comic book where Spider-Man was [mistakenly] addressed as Super-Man
Entering the US with dual citizenship but US passport is long expired?
What's this constructed number's starter?
Why does the UK Prime Minister need the permission of Parliament to call a general election?
Did the Byzantines ever attempt to move their capital to Rome?
How to create large inductors (1H) for audio use?
How do German speakers decide what should be on the left side of the verb?
What are some countries where you can be imprisoned for reading or owning a Bible?
What's the point of a PROTOTYPE macro that merely expands to its arguments?
Pronunciation of "sincero" and "sinceramente"
Is it right to use the ideas of non-winning designers in a design contest?
What drugs were used in England during the High Middle Ages?
Round away from zero
Why are some hotels asking you to book through Booking.com instead of matching the price at the front desk?
Does JavaScript ignore the remaining lines of code in a function after it makes a recursive call?
How to turn a String into a JavaScript function call?What does the function then() mean in JavaScript?Android Calling JavaScript functions in WebViewCalling a javascript function recursivelyWhy does JavaScript only work after opening developer tools in IE once?Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for itcheck for alpha only colors using javascriptWhy is my variable unaltered after I modify it inside of a function? - Asynchronous code referenceJavascript - unexpected result checking variable assignmentUnable to generate multiple Images
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am building a minesweeper game in JavaScript and I am running into a problem while trying to clear the adjacent empty cells when a cell without a mine is clicked.
I am using a function called clearEmptySpace() to check if the variable adjacentMines is greater than 0 on all cells adjacent to the one clicked.
If the adjacentMines variable is 0 on any of the checked cells I call the checkCell() function which uncovers the cell and then calls clearEmptySpace(), with the new cell location.
If clearEmptySpace() finds a cell with 1 or more adjacent mines it calls checkCell() with a flag to ensure clearEmptySpace() is not called again with that cell location.
The issue is clearEmptySpace() checks the cell directly above itself and when it finds the cell above it has an adjacentMines value of 0 it calls checkCell() with the cell position above itself as intended but does not continue checking the other directions after the function call is made.
The only time the next check (Upper left cell) is made is when the cell above has 1 or more adjacent mine and the following checkCell() does not re-call clearEmptySpace().
Is the second clearEmptySpace() call stopping the current clearEmptySpace() from further execution? if so how do I go about fixing this issue?
For simplicity's sake the clearEmptySpace() code provided only checks the cell directly above and the upper left cell.
function checkCell(cell,onlyOnce = false)
var cellLocation = cell.id.toString();
var clickedCell = cellLocation.split(',');
if(cellArray[clickedCell[0]][clickedCell[1]].hasMine)
cell.innerHTML = "M"
gameOver();
else
cellArray[clickedCell[0]][clickedCell[1]].flagged = false;
if(cellArray[clickedCell[0]][clickedCell[1]].adjacentMines > 0)
getFontColor(cell);
cell.innerHTML = cellArray[clickedCell[0]][clickedCell[1]].adjacentMines.toString();
else
cell.innerHTML = "0";
cell.style.backgroundColor = "#EBEBEB";
if(!onlyOnce && !cellArray[clickedCell[0]][clickedCell[1]].adjacentMines)
clearEmptySpace(cell);
cellArray[clickedCell[0]][clickedCell[1]].hidden = false;
_____________________________________________________________________________
function clearEmptySpace(inputCell)
var cellLocation = inputCell.id.toString();
var currentCell = cellLocation.split(',');
var targetCellLocation = new Array();
targetCellLocation = [currentCell[0]-1,currentCell[1]+1];
var targetCell = document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString());
if(currentCell[0] > 0)
if(!cellArray[currentCell[0]-1][currentCell[1]].adjacentMines)
alert("The cell directly above has no adjacent mines");
targetCellLocation = [currentCell[0]-1,currentCell[1]];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()));
else
alert("The cell directly above has at least one adjacent mine");
targetCellLocation = [currentCell[0]-1,currentCell[1]];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()),true);
if(currentCell[1] > 0 )
if(!cellArray[currentCell[0]-1][currentCell[1]-1].adjacentMines)
alert("The cell on the upper left has no adjacent mines");
targetCellLocation = [currentCell[0]-1,currentCell[1]-1];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()));
else
alert("The cell on the upper left has at least one adjacent mine");
targetCellLocation = [currentCell[0]-1,currentCell[1]-1];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()),true);
javascript
|
show 2 more comments
I am building a minesweeper game in JavaScript and I am running into a problem while trying to clear the adjacent empty cells when a cell without a mine is clicked.
I am using a function called clearEmptySpace() to check if the variable adjacentMines is greater than 0 on all cells adjacent to the one clicked.
If the adjacentMines variable is 0 on any of the checked cells I call the checkCell() function which uncovers the cell and then calls clearEmptySpace(), with the new cell location.
If clearEmptySpace() finds a cell with 1 or more adjacent mines it calls checkCell() with a flag to ensure clearEmptySpace() is not called again with that cell location.
The issue is clearEmptySpace() checks the cell directly above itself and when it finds the cell above it has an adjacentMines value of 0 it calls checkCell() with the cell position above itself as intended but does not continue checking the other directions after the function call is made.
The only time the next check (Upper left cell) is made is when the cell above has 1 or more adjacent mine and the following checkCell() does not re-call clearEmptySpace().
Is the second clearEmptySpace() call stopping the current clearEmptySpace() from further execution? if so how do I go about fixing this issue?
For simplicity's sake the clearEmptySpace() code provided only checks the cell directly above and the upper left cell.
function checkCell(cell,onlyOnce = false)
var cellLocation = cell.id.toString();
var clickedCell = cellLocation.split(',');
if(cellArray[clickedCell[0]][clickedCell[1]].hasMine)
cell.innerHTML = "M"
gameOver();
else
cellArray[clickedCell[0]][clickedCell[1]].flagged = false;
if(cellArray[clickedCell[0]][clickedCell[1]].adjacentMines > 0)
getFontColor(cell);
cell.innerHTML = cellArray[clickedCell[0]][clickedCell[1]].adjacentMines.toString();
else
cell.innerHTML = "0";
cell.style.backgroundColor = "#EBEBEB";
if(!onlyOnce && !cellArray[clickedCell[0]][clickedCell[1]].adjacentMines)
clearEmptySpace(cell);
cellArray[clickedCell[0]][clickedCell[1]].hidden = false;
_____________________________________________________________________________
function clearEmptySpace(inputCell)
var cellLocation = inputCell.id.toString();
var currentCell = cellLocation.split(',');
var targetCellLocation = new Array();
targetCellLocation = [currentCell[0]-1,currentCell[1]+1];
var targetCell = document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString());
if(currentCell[0] > 0)
if(!cellArray[currentCell[0]-1][currentCell[1]].adjacentMines)
alert("The cell directly above has no adjacent mines");
targetCellLocation = [currentCell[0]-1,currentCell[1]];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()));
else
alert("The cell directly above has at least one adjacent mine");
targetCellLocation = [currentCell[0]-1,currentCell[1]];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()),true);
if(currentCell[1] > 0 )
if(!cellArray[currentCell[0]-1][currentCell[1]-1].adjacentMines)
alert("The cell on the upper left has no adjacent mines");
targetCellLocation = [currentCell[0]-1,currentCell[1]-1];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()));
else
alert("The cell on the upper left has at least one adjacent mine");
targetCellLocation = [currentCell[0]-1,currentCell[1]-1];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()),true);
javascript
no, it does not. calling a function does not imply a return from the current function (recursion make no difference to this)
– Jaromanda X
Mar 28 at 4:50
When it encounters a recursive call, it will resolve it like any other function call - execute the function and when complete, continue with the next line. Whether the function call is to the same function or not is irrelevant.
– VLAZ
Mar 28 at 4:50
Did you check your browser's console? Your description points quite naturally to an Error thrown somewhere, or an infinite loop, in which case, yes, the remaining of the function would never happen. For us here, it's quite hard to get our heads over your code, recursion is often hard to follow just by reading, but here we are not even sure how your data is formatted. Can you please try to generate an minimal reproducible example (all the DOM references are probably not needed, your grid doesn't need to be quite big).
– Kaiido
Mar 28 at 4:58
when I add an alert that displays the cellLocation variable after the first check I never get the alert for any of the function calls except the last one where it cannot check the above tile because the y position is 0 and the check is ignored. so the rest of the checks are not being done by the initial function
– Borzoi Respecter
Mar 28 at 5:00
wow "alert" as inalert()? I missed that in your code... Yes, this does block js execution but it should restart after you close it. Now, please use the console to debug. And use it to log the values you are getting likeconsole.log(targetCellLocation, targetCell)
– Kaiido
Mar 28 at 5:01
|
show 2 more comments
I am building a minesweeper game in JavaScript and I am running into a problem while trying to clear the adjacent empty cells when a cell without a mine is clicked.
I am using a function called clearEmptySpace() to check if the variable adjacentMines is greater than 0 on all cells adjacent to the one clicked.
If the adjacentMines variable is 0 on any of the checked cells I call the checkCell() function which uncovers the cell and then calls clearEmptySpace(), with the new cell location.
If clearEmptySpace() finds a cell with 1 or more adjacent mines it calls checkCell() with a flag to ensure clearEmptySpace() is not called again with that cell location.
The issue is clearEmptySpace() checks the cell directly above itself and when it finds the cell above it has an adjacentMines value of 0 it calls checkCell() with the cell position above itself as intended but does not continue checking the other directions after the function call is made.
The only time the next check (Upper left cell) is made is when the cell above has 1 or more adjacent mine and the following checkCell() does not re-call clearEmptySpace().
Is the second clearEmptySpace() call stopping the current clearEmptySpace() from further execution? if so how do I go about fixing this issue?
For simplicity's sake the clearEmptySpace() code provided only checks the cell directly above and the upper left cell.
function checkCell(cell,onlyOnce = false)
var cellLocation = cell.id.toString();
var clickedCell = cellLocation.split(',');
if(cellArray[clickedCell[0]][clickedCell[1]].hasMine)
cell.innerHTML = "M"
gameOver();
else
cellArray[clickedCell[0]][clickedCell[1]].flagged = false;
if(cellArray[clickedCell[0]][clickedCell[1]].adjacentMines > 0)
getFontColor(cell);
cell.innerHTML = cellArray[clickedCell[0]][clickedCell[1]].adjacentMines.toString();
else
cell.innerHTML = "0";
cell.style.backgroundColor = "#EBEBEB";
if(!onlyOnce && !cellArray[clickedCell[0]][clickedCell[1]].adjacentMines)
clearEmptySpace(cell);
cellArray[clickedCell[0]][clickedCell[1]].hidden = false;
_____________________________________________________________________________
function clearEmptySpace(inputCell)
var cellLocation = inputCell.id.toString();
var currentCell = cellLocation.split(',');
var targetCellLocation = new Array();
targetCellLocation = [currentCell[0]-1,currentCell[1]+1];
var targetCell = document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString());
if(currentCell[0] > 0)
if(!cellArray[currentCell[0]-1][currentCell[1]].adjacentMines)
alert("The cell directly above has no adjacent mines");
targetCellLocation = [currentCell[0]-1,currentCell[1]];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()));
else
alert("The cell directly above has at least one adjacent mine");
targetCellLocation = [currentCell[0]-1,currentCell[1]];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()),true);
if(currentCell[1] > 0 )
if(!cellArray[currentCell[0]-1][currentCell[1]-1].adjacentMines)
alert("The cell on the upper left has no adjacent mines");
targetCellLocation = [currentCell[0]-1,currentCell[1]-1];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()));
else
alert("The cell on the upper left has at least one adjacent mine");
targetCellLocation = [currentCell[0]-1,currentCell[1]-1];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()),true);
javascript
I am building a minesweeper game in JavaScript and I am running into a problem while trying to clear the adjacent empty cells when a cell without a mine is clicked.
I am using a function called clearEmptySpace() to check if the variable adjacentMines is greater than 0 on all cells adjacent to the one clicked.
If the adjacentMines variable is 0 on any of the checked cells I call the checkCell() function which uncovers the cell and then calls clearEmptySpace(), with the new cell location.
If clearEmptySpace() finds a cell with 1 or more adjacent mines it calls checkCell() with a flag to ensure clearEmptySpace() is not called again with that cell location.
The issue is clearEmptySpace() checks the cell directly above itself and when it finds the cell above it has an adjacentMines value of 0 it calls checkCell() with the cell position above itself as intended but does not continue checking the other directions after the function call is made.
The only time the next check (Upper left cell) is made is when the cell above has 1 or more adjacent mine and the following checkCell() does not re-call clearEmptySpace().
Is the second clearEmptySpace() call stopping the current clearEmptySpace() from further execution? if so how do I go about fixing this issue?
For simplicity's sake the clearEmptySpace() code provided only checks the cell directly above and the upper left cell.
function checkCell(cell,onlyOnce = false)
var cellLocation = cell.id.toString();
var clickedCell = cellLocation.split(',');
if(cellArray[clickedCell[0]][clickedCell[1]].hasMine)
cell.innerHTML = "M"
gameOver();
else
cellArray[clickedCell[0]][clickedCell[1]].flagged = false;
if(cellArray[clickedCell[0]][clickedCell[1]].adjacentMines > 0)
getFontColor(cell);
cell.innerHTML = cellArray[clickedCell[0]][clickedCell[1]].adjacentMines.toString();
else
cell.innerHTML = "0";
cell.style.backgroundColor = "#EBEBEB";
if(!onlyOnce && !cellArray[clickedCell[0]][clickedCell[1]].adjacentMines)
clearEmptySpace(cell);
cellArray[clickedCell[0]][clickedCell[1]].hidden = false;
_____________________________________________________________________________
function clearEmptySpace(inputCell)
var cellLocation = inputCell.id.toString();
var currentCell = cellLocation.split(',');
var targetCellLocation = new Array();
targetCellLocation = [currentCell[0]-1,currentCell[1]+1];
var targetCell = document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString());
if(currentCell[0] > 0)
if(!cellArray[currentCell[0]-1][currentCell[1]].adjacentMines)
alert("The cell directly above has no adjacent mines");
targetCellLocation = [currentCell[0]-1,currentCell[1]];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()));
else
alert("The cell directly above has at least one adjacent mine");
targetCellLocation = [currentCell[0]-1,currentCell[1]];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()),true);
if(currentCell[1] > 0 )
if(!cellArray[currentCell[0]-1][currentCell[1]-1].adjacentMines)
alert("The cell on the upper left has no adjacent mines");
targetCellLocation = [currentCell[0]-1,currentCell[1]-1];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()));
else
alert("The cell on the upper left has at least one adjacent mine");
targetCellLocation = [currentCell[0]-1,currentCell[1]-1];
checkCell(document.getElementById(targetCellLocation[0].toString()+","+targetCellLocation[1].toString()),true);
javascript
javascript
asked Mar 28 at 4:48
Borzoi RespecterBorzoi Respecter
1
1
no, it does not. calling a function does not imply a return from the current function (recursion make no difference to this)
– Jaromanda X
Mar 28 at 4:50
When it encounters a recursive call, it will resolve it like any other function call - execute the function and when complete, continue with the next line. Whether the function call is to the same function or not is irrelevant.
– VLAZ
Mar 28 at 4:50
Did you check your browser's console? Your description points quite naturally to an Error thrown somewhere, or an infinite loop, in which case, yes, the remaining of the function would never happen. For us here, it's quite hard to get our heads over your code, recursion is often hard to follow just by reading, but here we are not even sure how your data is formatted. Can you please try to generate an minimal reproducible example (all the DOM references are probably not needed, your grid doesn't need to be quite big).
– Kaiido
Mar 28 at 4:58
when I add an alert that displays the cellLocation variable after the first check I never get the alert for any of the function calls except the last one where it cannot check the above tile because the y position is 0 and the check is ignored. so the rest of the checks are not being done by the initial function
– Borzoi Respecter
Mar 28 at 5:00
wow "alert" as inalert()? I missed that in your code... Yes, this does block js execution but it should restart after you close it. Now, please use the console to debug. And use it to log the values you are getting likeconsole.log(targetCellLocation, targetCell)
– Kaiido
Mar 28 at 5:01
|
show 2 more comments
no, it does not. calling a function does not imply a return from the current function (recursion make no difference to this)
– Jaromanda X
Mar 28 at 4:50
When it encounters a recursive call, it will resolve it like any other function call - execute the function and when complete, continue with the next line. Whether the function call is to the same function or not is irrelevant.
– VLAZ
Mar 28 at 4:50
Did you check your browser's console? Your description points quite naturally to an Error thrown somewhere, or an infinite loop, in which case, yes, the remaining of the function would never happen. For us here, it's quite hard to get our heads over your code, recursion is often hard to follow just by reading, but here we are not even sure how your data is formatted. Can you please try to generate an minimal reproducible example (all the DOM references are probably not needed, your grid doesn't need to be quite big).
– Kaiido
Mar 28 at 4:58
when I add an alert that displays the cellLocation variable after the first check I never get the alert for any of the function calls except the last one where it cannot check the above tile because the y position is 0 and the check is ignored. so the rest of the checks are not being done by the initial function
– Borzoi Respecter
Mar 28 at 5:00
wow "alert" as inalert()? I missed that in your code... Yes, this does block js execution but it should restart after you close it. Now, please use the console to debug. And use it to log the values you are getting likeconsole.log(targetCellLocation, targetCell)
– Kaiido
Mar 28 at 5:01
no, it does not. calling a function does not imply a return from the current function (recursion make no difference to this)
– Jaromanda X
Mar 28 at 4:50
no, it does not. calling a function does not imply a return from the current function (recursion make no difference to this)
– Jaromanda X
Mar 28 at 4:50
When it encounters a recursive call, it will resolve it like any other function call - execute the function and when complete, continue with the next line. Whether the function call is to the same function or not is irrelevant.
– VLAZ
Mar 28 at 4:50
When it encounters a recursive call, it will resolve it like any other function call - execute the function and when complete, continue with the next line. Whether the function call is to the same function or not is irrelevant.
– VLAZ
Mar 28 at 4:50
Did you check your browser's console? Your description points quite naturally to an Error thrown somewhere, or an infinite loop, in which case, yes, the remaining of the function would never happen. For us here, it's quite hard to get our heads over your code, recursion is often hard to follow just by reading, but here we are not even sure how your data is formatted. Can you please try to generate an minimal reproducible example (all the DOM references are probably not needed, your grid doesn't need to be quite big).
– Kaiido
Mar 28 at 4:58
Did you check your browser's console? Your description points quite naturally to an Error thrown somewhere, or an infinite loop, in which case, yes, the remaining of the function would never happen. For us here, it's quite hard to get our heads over your code, recursion is often hard to follow just by reading, but here we are not even sure how your data is formatted. Can you please try to generate an minimal reproducible example (all the DOM references are probably not needed, your grid doesn't need to be quite big).
– Kaiido
Mar 28 at 4:58
when I add an alert that displays the cellLocation variable after the first check I never get the alert for any of the function calls except the last one where it cannot check the above tile because the y position is 0 and the check is ignored. so the rest of the checks are not being done by the initial function
– Borzoi Respecter
Mar 28 at 5:00
when I add an alert that displays the cellLocation variable after the first check I never get the alert for any of the function calls except the last one where it cannot check the above tile because the y position is 0 and the check is ignored. so the rest of the checks are not being done by the initial function
– Borzoi Respecter
Mar 28 at 5:00
wow "alert" as in
alert()? I missed that in your code... Yes, this does block js execution but it should restart after you close it. Now, please use the console to debug. And use it to log the values you are getting like console.log(targetCellLocation, targetCell)– Kaiido
Mar 28 at 5:01
wow "alert" as in
alert()? I missed that in your code... Yes, this does block js execution but it should restart after you close it. Now, please use the console to debug. And use it to log the values you are getting like console.log(targetCellLocation, targetCell)– Kaiido
Mar 28 at 5:01
|
show 2 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390349%2fdoes-javascript-ignore-the-remaining-lines-of-code-in-a-function-after-it-makes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390349%2fdoes-javascript-ignore-the-remaining-lines-of-code-in-a-function-after-it-makes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
no, it does not. calling a function does not imply a return from the current function (recursion make no difference to this)
– Jaromanda X
Mar 28 at 4:50
When it encounters a recursive call, it will resolve it like any other function call - execute the function and when complete, continue with the next line. Whether the function call is to the same function or not is irrelevant.
– VLAZ
Mar 28 at 4:50
Did you check your browser's console? Your description points quite naturally to an Error thrown somewhere, or an infinite loop, in which case, yes, the remaining of the function would never happen. For us here, it's quite hard to get our heads over your code, recursion is often hard to follow just by reading, but here we are not even sure how your data is formatted. Can you please try to generate an minimal reproducible example (all the DOM references are probably not needed, your grid doesn't need to be quite big).
– Kaiido
Mar 28 at 4:58
when I add an alert that displays the cellLocation variable after the first check I never get the alert for any of the function calls except the last one where it cannot check the above tile because the y position is 0 and the check is ignored. so the rest of the checks are not being done by the initial function
– Borzoi Respecter
Mar 28 at 5:00
wow "alert" as in
alert()? I missed that in your code... Yes, this does block js execution but it should restart after you close it. Now, please use the console to debug. And use it to log the values you are getting likeconsole.log(targetCellLocation, targetCell)– Kaiido
Mar 28 at 5:01