May 06, 2021 JavaScript
JavaScript is a programming language. Grammar rules define the language structure.
JavaScript is a scripting language.
It is a lightweight but powerful programming language.
In a programming language, a word is a constant, such as 3.14.
The literal quantity of number can be an integer or a small number, or a scientific count (e).
String literally can be used in single or double quotes:
The literal amount of the expression is used to evaluate:
Array literally defines an array:
Object literally defines an object:
Function literally defines a function:
In a programming language, variables are used to store data values.
JavaScript uses the keyword var to define variables, and uses equal numbers to assign values to variables:
Variables can be accessed by variable names. I n instructional languages, variables are usually variable. The literal quantity is a constant value.
The variable is a name. The literal quantity is a value. |
JavaScript uses arithmetic operators to calculate values:
JavaScript uses the assignment operator to assign values to variables:
The JavaScript language has several types of operators:
Type | Instance | Describe |
---|---|---|
Assignments, arithmetic, and bit operators | = + - * / | Described in the JS operator |
Conditions, comparisons, and logical operators | == != < > | Described in the JS comparison operator |
In HTML, javaScript statements issue commands to the browser. The browser knows what to do with the JavaScript statement.
Statements are separated by a sign:
JavaScript statements usually begin with a keyword. Var keywords tell the browser to create a new variable:
Like any other programming language, JavaScript retains some identifiers for its own use.
JavaScript also retains keywords that are not used in the current language version, but will be used in future JavaScript extensions.
The JavaScript identifier must start with a letter, underscore, or a dollar sign ($).
Subsequent characters can be letters, numbers, underscores, or dollar characters (numbers are not allowed as first characters so javaScript can easily separate identifiers and numbers).
Here are the most important reserved words in JavaScript(alphabetical):
abstract | else | instanceof | super |
boolean | Enum | Int | switch |
break | export | interface | synchronized |
byte | extends | let | this |
case | false | long | throw |
Catch | final | native | throws |
char | finally | new | transient |
class | float | Null | true |
const | for | package | try |
continue | function | private | typeof |
debugger | Goto | protected | Var |
default | if | public | void |
delete | implements | return | volatile |
do | import | short | while |
double | in | static | with |
Not all JavaScript statements are "commands." The content after the // will be ignored by the browser:
JavaScript has several data types: numbers, strings, arrays, objects, and so on:
Data types are a very important part of programming languages.
In order to manipulate variables, it is important to understand the concept of data types.
If you do not use data types, the following instances will not be executed:
16 Plus "Volvo" how is it calculated? Does this result in an error or output the following results?
You can try to execute the above code in your browser to see the effect.
You'll learn more about data types in the next chapters.
JavaScript statements can be written within functions, which can be repeatedly referenced:
Refers to a function , which calls a function (executes a statement within a function).
JavaScript is case sensitive.
When writing JavaScript statements, be careful whether to turn off the case switch key.
The function getElementById is different from the getElementbyID.
Similarly, the variable myVariable is different from MyVariable.
Tip: In this site's programming practice, you can practice understanding the case sensitivity of JavaScript variables.
JavaScript uses Unicode character sets.
Unicode overrides all characters, including characters such as punctuation.
For further information, learn from our complete Unicode reference manual.
In JavaScript, it is common to name rules for hump methods, such as lastName (not lastname). |
JavaScript is the scripting language. T he browser executes the script code line by line as it reads the code. For traditional programming, all code is compiled before execution. |