- JavaScript Introduction
- JavaScript Where To
- JavaScript Output
- JavaScript Statements
- JavaScript Syntax
- JavaScript Comments
- JavaScript Variables
- JavaScript Let
- JavaScript Const
- JavaScript Operators
- JavaScript Arithmetic
- JavaScript Assignment
- JavaScript Data Types
- JavaScript Functions
- JavaScript Objects
- JavaScript Events
- JavaScript Strings
- JavaScript String Methods
- JavaScript Numbers
- JavaScript Number Methods
- JavaScript Arrays
- JavaScript Array Const
- JavaScript Array Methods
- JavaScript Sorting Arrays
- JavaScript Array Iteration
- JavaScript Date Objects
- JavaScript Date Formats
- JavaScript Get Date Methods
- JavaScript Set Date Methods
- JavaScript Math Object
- JavaScript Random
- JavaScript Booleans
- JavaScript Comparison And Logical Operators
- JavaScript If Else And Else If
- JavaScript Switch Statement
- JavaScript For Loop
- JavaScript Break And Continue
- JavaScript Type Conversion
- JavaScript Bitwise Operations
- JavaScript Regular Expressions
- JavaScript Errors
- JavaScript Scope
- JavaScript Hoisting
- JavaScript Use Strict
- The JavaScript This Keyword
- JavaScript Arrow Function
- JavaScript Classes
- JavaScript JSON
- JavaScript Debugging
- JavaScript Style Guide
- JavaScript Best Practices
- JavaScript Common Mistakes
- JavaScript Performance
- JavaScript Reserved Words
- JavaScript Versions
- JavaScript History
- JavaScript Forms
- JavaScript Validation API
- JavaScript Objects
- JavaScript Object Properties
- JavaScript Function Definitions
- JavaScript Function Parameters
- JavaScript Function Invocation
- JavaScript Closures
- JavaScript Classes
- Java Script Async
- JavaScript HTML DOM
- The Browser Object Model
- JS Ajax
- JavaScript JSON
- JavaScript Web APIs
- JS Vs JQuery
JavaScript Statements
JavaScript Programs
A list of "instructions" for a computer to "execute" makes up a computer programme.
These programming directives are known as statements in a programming language.
A set of programming statements makes up a JavaScript programme.
The web browser runs JavaScript scripts when they are embedded in HTML.
x = 5; // Statement 2
y = 6; // Statement 3
z = x + y; // Statement 4
JavaScript Statements
JavaScript statements include the following:
Expressions, Values, Operators, Comments, and Expressions.
The following command instructs the browser to insert "Hello Dolly." into an HTML element with the id="demo":
Many JavaScript statements can be found in most JavaScript apps.
The assertions are carried out sequentially in the order they are written.
The term "JavaScript code" is frequently used to refer to JavaScript programmes and statements.
Semicolons ;
Statements in JavaScript are divided by semicolons.
Each executable statement should have a semicolon at the end:
a = 5; // Assign the value 5 to a
b = 6; // Assign the value 6 to b
c = a + b; // Assign the sum of a and b to c
???????
Although not compulsory, using a semicolon to end a sentence is highly advised.
???????
JavaScript White Space
JavaScript disregards extra spaces. To make your script easier to read, add white space.
equivalent lines are as follows:
var person="Hege";
Placing spaces around operators (= + - * /) is a good idea:
???????
JavaScript Line Length And Line Breaks
Programmers frequently want to keep code lines around 80 characters in length for the best readability.
The optimal place to break a JavaScript statement if it cannot fit on a single line is after an operator:
"Hello Dolly!";
JavaScript Code Blocks
JavaScript statements can be condensed into code blocks by enclosing them in curly brackets. {..}
Code blocks are used to specify statements that will run concurrently.
JavaScript functions are one area where blocks of statements can be found:
document.getElementById("demo1").innerHTML = "Hello Dolly!";
document.getElementById("demo2").innerHTML = "How are you?";
}
JavaScript Keywords
In order to specify the JavaScript action that is to be carried out, JavaScript statements frequently begin with a keyword.
A complete list of JavaScript keywords can be found in our reference on Reserved Words.
Some of the terms you will learn about in this tutorial are listed below:
Keyword | Description |
---|---|
break | Terminates a switch or a loop |
continue | Jumps out of a loop and starts at the top |
debugger | Stops the execution of JavaScript, and calls (if available) the debugging function |
do ... while | Executes a block of statements, and repeats the block, while a condition is true |
for | Marks a block of statements to be executed, as long as a condition is true |
function | Declares a function |
if ... else | Marks a block of statements to be executed, depending on a condition |
return | Exits a function |
switch | Marks a block of statements to be executed, depending on different cases |
try ... catch | Implements error handling to a block of statements |
var | Declares a variable |
JavaScript keywords are reserved words. Reserved words cannot be used as names for variables.
Products
Partner
Copyright © RVR Innovations LLP 2024 | All rights reserved - Mytat.co is the venture of RVR Innovations LLP