Category «Javascript»

JavaScript Loops while, for, do while

javascript

JavaScript Loops JavaScript loops are used to execute the same code multiple times. They can execute a block of code as long as a specified condition is true.   The While Loop The while loop execute a block of code as long as a specified condition is true. The While loop has the following syntax: …

JavaScript conditional statements

javascript

If statement The if statement is used to specify a block of JavaScript code that is executed, if a condition is true.   Example If You want to execute a single line of code in an if statement, is not necessarily to put curly braces in. However it’s a good practice to always use curly …

Javascript output, alert, console.log, innerHTML

javascript

About JavaScript Output JavaScript does not have built-in functions for display, but we are able to display data in different ways: into an alert box, using alert() method which displays an alert box with a specified message;   into the browser console, using console.log(). You may pass as many arguments as you’d like;   into …

Javascript variables, rules, examples

javascript

In other programming languages when you define a variable, you must specify its type, ie what type of information will be stored in the variable, like integer, boolean, array, etc; JavaScript is different! In JavaScript we create a generic variable and then put whatever type of value we want in it. To create a variable …

About JavaScript code, examples

javascript

JavaScript is an interpreted, object-oriented language and is known as the scripting language for web pages. How to add javascript code in HTML? In HTML pages, JavaScript code must be placed between <script> and </script> tags. There are old javascript examples that use “type attribute” inside <script> tag like: The type attribute is not required …