JavaScript Break and Continue Statements

JavaScript Break and Continue Statements

The break StatementThe break statement will break the loop and continue executing the code that follows after the loop (if any).


var i=0;
for (i=0;i<=10;i++)
{
if (i==3)
{
break;
}
document.write("The number is " + i);
document.write("
");
}




output

The number is 0
The number is 1
The number is 2

The continue StatementThe continue statement will break the current loop and continue with the next value.



var i=0
for (i=0;i<=10;i++)
{
if (i==3)
{
continue;
}
document.write("The number is " + i);
document.write("
");
}




output

The number is 0
The number is 1
The number is 2
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9
The number is 10

JavaScript For...In Statement
The for...in statement loops through the elements of an array or through the properties of an object.




var x;
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";

for (x in mycars)
{
document.write(mycars[x] + "
");
}





output

Saab
Volvo
BMW

Read Users' Comments (0)

Interview Questions with answers

Transactions :


database level transactions

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[csp_DeleteExamQuestion]
@intExaminationQuestionId int,
@intIsSucess int OUTPUT
AS
BEGIN
DECLARE @intExaminationId AS INT
DECLARE @intQuestionSeqId AS TINYINT
DECLARE @intSectionId AS TINYINT

SET @intIsSucess = 0;
BEGIN TRANSACTION
BEGIN TRY
SELECT
@intExaminationId = intExaminationId ,
@intQuestionSeqId = intQuestionSeqId,
@intSectionId = intSectionId
FROM tblExaminationQuestion
WHERE intExaminationQuestionId = @intExaminationQuestionId

Print @intExaminationId
Print @intQuestionSeqId

DELETE FROM tblExaminationQuestion
WHERE intExaminationQuestionId = @intExaminationQuestionId

UPDATE tblExaminationQuestion
SET intQuestionSeqId = (intQuestionSeqId -1)
WHERE intExaminationId = @intExaminationId
AND intSectionId = @intSectionId
AND intQuestionSeqId > @intQuestionSeqId

SET @intIsSucess = 1
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;

IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;
END CATCH;

IF @@TRANCOUNT > 0
BEGIN
COMMIT TRANSACTION;
SET @intIsSucess = 1
END

RETURN @intIsSucess

END


Ado.net Level Transactions :


public int AddExaminationSections(bool isAdd,
List examinationSectionList)
{
int returnId = 0;

try
{
using (TransactionScope scope = new TransactionScope())
{
int returnExaminationSectionId = 0;
bool tempIsAdd = true;
foreach (ExaminationSection examinationSection in examinationSectionList)
{
if (examinationSection != null)
{
if (!isAdd && examinationSection.ExaminationSectionId > 0)
{
tempIsAdd = false;
}
}

returnExaminationSectionId = AddExaminationSection(tempIsAdd,
examinationSection.ExaminationSectionId,
examinationSection.ExaminationId,
examinationSection.SectionId,
examinationSection.NoOfQuestions);

if (returnExaminationSectionId > 0)
{
returnId = examinationSection.ExaminationId;
}
else
{
return 0;
}
}

if (returnExaminationSectionId > 0)
{
scope.Complete();
//returnId = examinationSection.;
}
}
}
catch (Exception ex)
{
ELearning.ErrorLogger.Error.WriteErrorLog(ex);
}
return returnId;
}

Read Users' Comments (0)

Interview Training

Essential List :


1. Transaction code(with ACID definition rule)
2. SQL queries inner join/outer join as well(nearly 5 queries)
3. Learn Sub queries
4. Cashing concepts
5. how to code web config configurations like database connection string settings like
6. why do we use "using" statement in our code
7. special SQL queries like(Select top 5)
8. use Share point - work flows
9. ASP.net - use validates
10. what is the different between server.transfer vs response.redirect?
11. use custom validates and range validates(when to use)
12. Basic definitions of LINQ
13. Basic understanding about State management
14. Basic understanding about ADO.NET

Read Users' Comments (0)