
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10483 Articles for Web Development

918 Views
A block statement groups zero or more statements. In languages other than JavaScript, it is known as a compound statement.SyntaxHere’s the syntax −{ //List of statements }Variables with a block get scoped to the containing function. Block statement never introduce scope and using var to declare variables don’t have block scope.var a = 20; { var b = 40; }Now, when you will print the value of a, it will print 40, not 20. This is because variable declared with a var within the block has the same scope like var before the block.var a = 20; { var a = 40; } // this prints 40 document.write(a);

563 Views
Break without labelThe break statement is used to exit a loop early, breaking out of the enclosing curly braces. The break statement exits out of a loop. ExampleLet’s see an example of break statement in JavaScript without using label −Live Demo var x = 1; document.write("Entering the loop "); while (x < 20) { if (x == 5){ break; // breaks out ... Read More

201 Views
The most common way to define a function in JavaScript is by using the “function” keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces.SyntaxHere’s the syntax − Try the following example. It defines a function called sayHello that takes no parameters,

11K+ Views
To compare two strings in JavaScript, use the localeCompare() method. The method returns 0 if both the strings are equal, -1 if string 1 is sorted before string 2 and 1 if string 2 is sorted before string 1.ExampleYou can try to run the following code to compare two stringsLive Demo Compare Strings function compareStr() { var string1 = "World"; var string2 = "World"; var result = string1.localeCompare(string2); document.getElementById("test").innerHTML = result; }

2K+ Views
In this tutorial, we will learn to reverse a string in place in JavaScript. How to reverse a string is one of the most popular questions asked in the interview of freshers. It’s an easy task but the interviewer can be tricky and make the same question difficult for you. For example, what if the interviewer asks you to write a pseudo code to reverse a string in place without using the extra space? You should have an answer ready in your mind for this kind of tricky question.There are lots of ways to reverse a string. As developers develop ... Read More

974 Views
The “for” loop includes loop initialization where we initialize our counter to a starting value. The initialization statement is executed before the loop begins, the test statement which will test if a given condition is true or not. If the condition is true, then the code given inside the loop will be executed, otherwise, the control will come out of the loop.At the end comes the iteration statement where you can increase or decrease your counter. Let us see how to show for loop using flowchart in JavaScript −

1K+ Views
An alert dialog box is mostly used to give a warning message to the users. For example, if one input field requires to enter some text but the user does not provide any input, then as a part of validation, you can use an alert box to give a warning message.Nonetheless, an alert box can still be used for friendlier messages. Alert box gives only one button "OK" to select and proceed.ExampleYou can try to run the following code to learn how to add an alert box −Live Demo Click the following button to see the result: