JavaScript syntax is a set of rules for how JavaScript programs are created. In this lesson we will look at the basic lexical structures of the language.

Character set

When writing programs in JavaScript, the Unicode character set is used. Unlike 7-bit encoding, which is only suitable for in English, and an 8-bit encoding suitable only for English and major Western European languages, 16-bit Unicode supports virtually every written language on the planet. The ECMAScript v3 standard requires JavaScript implementations to support Unicode version 2.1 or higher, and the ECMAScript v5 standard requires implementations to support Unicode version 3 or higher.

Var str = "hello, world!"; // Latin alphabet is used var str = "Hello, world!"; // Use Cyrillic

Whitespace characters

Whitespace improves readability source code, but these symbols are generally not needed for js script functionality.

Whitespace characters
Character code Name Reduction Description Escape sequence
U+0009 Horizontal tabulation Moves the print position to the next horizontal tab stop \t
U+000B Vertical tab Moves the print position to the next vertical tab stop \v
U+000C Page feed, page change Throws out the current page and starts printing from the next one \f
U+0020 Space Letter spacing
U+00A0 Non-breaking space A character that appears inside a line like a regular space, but does not allow the line to be broken at that point

In addition to whitespace characters, end-of-line characters are also used to improve the readability of source text. However, in some cases, end-of-line characters can affect execution JavaScript code, since there are several moments when their use is prohibited. End of line characters also affect the process automatic installation semicolons.

The following characters are recognized by JavaScript interpreters as end-of-line characters:

Semicolon

A JavaScript program (script) is a list of “instructions” that are executed by a web browser.
In JavaScript, statements are typically separated by semicolons (;).

If several instructions are located on one line, then a semicolon (;) should be placed between them.

In many cases, JavaScript interprets a newline as a command separator to automatically enter semicolons (ASI) to terminate statements.
If each instruction is placed on a separate line, then the separator can be omitted:

One instruction can be located on several lines:

In this case, JavaScript waits for the expression to complete and therefore does not automatically insert a “virtual” semicolon between the lines.

Note: Although semicolons at the end of statements are optional, it is recommended to always add them. Now this is a rule that all large projects follow.

This rule prevents some errors, such as uncompleted input, and also allows you to compress code by removing white space. Compressing code without semicolons results in syntax errors. In addition, the presence of semicolons prevents performance degradation because parsers try to correct suspected errors by adding missing semicolons.

Case sensitivity

JavaScript programs are written using the Unicode character set, which includes the ASCII and Latin-1 character sets and is supported by almost all languages ​​and platforms.
In JavaScript, all elements, including variable, function, and operator names, are case sensitive and must always contain the same set of uppercase and lowercase letters. For example, keyword while should be typed as "while", not "While" or "WHILE".

Similarly, num, NUM and Num are three different variables:

Comments

Comments allow you to highlight a fragment of a program that is not executed by the JavaScript interpreter, but serves only to explain the content of the program.
Comments in JS can be single-line or multi-line.

Single-line comments begin with a double slash // . The text is considered a comment until the end of the line:

A multiline comment begins with a slash and an asterisk (/*) and ends with them in reverse order(*/) . This way you can comment out one or more lines:

Advice: Don't neglect comments in your codes. They will be useful to you when debugging and maintaining programs. At the development stage it may be better to comment out unnecessary fragment programs than just uninstalling them. What if it has to be restored?

Identifiers

An identifier is a sequence of letters, numbers, underscores (_), and dollar signs ($). A number cannot be the first character of an identifier because it would make it harder for the JavaScript interpreter to distinguish identifiers from numbers. Identifiers act as names of variables, functions, object properties, etc.
For compatibility and ease of editing, only ASCII characters and numbers are typically used to compose identifiers. However, in ECMAScript v3, identifiers can contain letters and numbers from the full Unicode character set. This allows programmers to name variables in their native languages ​​and use mathematical symbols in them:

Var name = "Max"; var Π = 3.14;

Historically, programmers have used different ways combining multiple words to record identifiers. Today there are two established unspoken styles: camelCase and snake_case.
In JavaScript, the most popular naming style for multi-word identifiers is camelCase notation. This means that the first letter is lowercase, and the first letters of all subsequent words are uppercase, for example:

Var firstSecond; var myCar = "audi"; var doSomethingImportant;

Attention: In JavaScript, combining multiple words to write identifiers using hyphens is not allowed. They are reserved for mathematical subtractions.

On a note: In JavaScript, keywords, reserved words and true values, false and null cannot be identifiers.

Keywords and reserved words

The ECMA-262 standard defines a set of keywords that cannot be used as identifiers. Reserved words have specific value in JavaScript because they are part of the language syntax. Using reserved words will result in a compilation error when loading the script.

Reserved keywords according to ECMAScript® 2015 version

  • break
  • catch
  • class
  • const
  • continue
  • debugger
  • default
  • delete
  • export
  • extends
  • finally
  • function
  • import
  • instanceof
  • return
  • super
  • switch
  • throw
  • typeof
  • while
  • yield

Keywords reserved for future use

In addition, ECMA-262 contains a set of reserved words, which also cannot be used as identifiers or property names. There is currently no functionality behind them, but it may appear in future versions:

  • await

In strict mode, the following words are added to this list:

  • implements
  • package
  • protected
  • static
  • interface
  • private
  • public

Reserved keywords in ECMAScript® versions 1 to 3

  • abstract
  • boolean
  • double
  • final
  • float
  • native
  • short
  • synchronized
  • transient
  • volatile

In the 5th edition of ECMAScript, the rules for using keywords and reserved words have been slightly changed. As before, they cannot be identifiers, but now they can be used as property names in objects. However, to ensure compatibility with past and future editions of ECMAScript, it is still best not to use keywords and reserved words as identifiers and property names.

Results

  • The JavaScript interpreter ignores any whitespace that may be present between language constructs and treats the program text as a continuous stream of code.
    Additionally, JavaScript also, for the most part, ignores newline characters. Therefore, spaces and newline characters can be used without restrictions in the source code of programs to format and give them a readable appearance.
  • Omitting semicolons is not considered good programming practice, and it is therefore advisable to develop the habit of using them.
  • In JavaScript, all elements, including variable, function, and operator names, are case sensitive and must always contain the same set of uppercase and lowercase letters.
  • Don't neglect comments in your codes. They will be useful to you when debugging and maintaining programs. Don't worry about increasing the code size because... There are JavaScript compression tools that will easily remove comments when published.
  • Identifiers act as names of variables, functions, object properties and consist of a sequence of letters, numbers, underscores (_) and dollar signs ($) .
  • JavaScript keywords used to denote elements of language syntax, as well as other words reserved for future use, cannot be used as names of variables, functions, or objects.

JavaScript Syntax

Since 1995, JavaScript has come a long way from a humble component of the Netscape browser to today's high-performance JIT interpreters. It would seem that just five years ago developers were stunned by the emergence of Ajax, and now complex JavaScript applications have reached volumes of hundreds and thousands of lines of code.

Last year, a new generation of JavaScript applications appeared that looked no different from desktop applications, an incredible advancement in web technology. Gone are slow page requests every time a user interacts with the application. JavaScript engines have become so powerful that it is possible to save state on the client side, which significantly speeds up the responsiveness of the application and improves the quality of its performance.

If you know other programming languages, you may find it helpful to know that JavaScript is a high-level, dynamic, untyped, and interpreted programming language that is well suited for object-oriented and functional programming styles. JavaScript inherited its syntax from Java language, its first-class functions come from the Scheme language, and its prototype-based inheritance mechanism comes from the Self language. But you don't need to know all of these languages ​​or be familiar with their terminology to learn JavaScript.

In this article we will look at the basic lexical structures of the language.

Symbols

When writing programs in JavaScript, the Unicode character set is used. Unicode is a superset of the ASCII and Latin-1 encodings and supports virtually every written language on the planet. Standard ECMAScript 3 requires JavaScript implementations to support the Unicode standard version 2.1 or later, and the ECMAScript 5 standard requires implementations to support the Unicode standard version 3 or later.

Case sensitivity

JavaScript is a case-sensitive language. This means that keywords, variable and function names, and any other language identifiers must always contain the same set of uppercase and lowercase letters.

For example, the while keyword should be typed as "while" rather than "While" or "WHILE". Similarly, myvar, Myvar, MyVar and MYVAR are the names of four different variables. Note, however, that HTML markup language (unlike XHTML) is not case sensitive. Since HTML and client-side JavaScript are closely related, this distinction can be confusing. Many JavaScript objects and their properties have the same names as tags and attributes HTML language which they represent. However, while in HTML these tags and attributes can be typed in any case, in JavaScript they usually must be typed in lowercase letters.

For example, the onclick attribute of an event handler is most often specified as onClick in HTML, but in JavaScript code (or in an XHTML document) it must be designated as onclick.

Spaces, newlines, and format control characters

JavaScript ignores spaces that may be present between tokens in a program. Additionally, JavaScript also largely ignores newlines. Therefore, spaces and newline characters can be used without restrictions in the source code of programs to format and give them a readable appearance.

In addition to the regular space character (\u0020), JavaScript additionally recognizes the following characters as whitespace: tab (\u0009), vertical tab (\u000B), format feed (\u000C), non-breaking space (\u00A0), byte order marker (\uFEFF ), as well as all Unicode characters classified as Zs.

The following characters are recognized as end-of-line characters by JavaScript interpreters: line feed (\u000A), carriage return (\u000D), line separator (\u2028) and paragraph separator (\u2029). The sequence of carriage return and line feed characters is interpreted as a single line termination character.

Unicode format control characters (category Cf), such as RIGHT-TO-LEFT MARK (\u200F) and LEFT-TO-RIGHT MARK (\u200E), control the visual presentation of the text in which they appear. They are important for the correct display of text in some languages ​​and are valid in JavaScript comments, string literals, and in literals regular expressions, but not in identifiers (such as variable names) defined in JavaScript programs. The exceptions are ZERO WIDTH JOINER (\u200D ) and ZERO WIDTH NON-JOINER (\u200C ), which can be used in identifiers provided that they are not the first characters of the identifiers.

You can view the complete table of Unicode characters on the Unicode Table website.

Optional semicolons

Like other programming languages, JavaScript uses a semicolon (;) to separate statements from each other. The use of semicolons has important to clearly express the programmer's intentions: without this separator, the end of one instruction can be mistaken for the beginning of the next and vice versa.

Typically in JavaScript you don't have to put a semicolon between statements if they are on different lines. (The semicolon can also be omitted at the end of the program or if the next token in the program is a closing curly brace.) Many JavaScript programmers use semicolons to explicitly mark the ends of statements, even when they are not necessary.

Take a look at the following snippet. Since the two statements are on different lines, the first semicolon can be omitted:

However, if these instructions are written as shown below, the first semicolon becomes required:

Comments

JavaScript supports two ways of formatting comments. Any text between the // characters and the end of the line is treated as a comment and is ignored by JavaScript. Any text between the characters /* and */ is also considered a comment. These comments can span multiple lines, but cannot be nested. The following lines are valid JavaScript comments:

// This is a one-line comment. /* This is also a comment */ // and this is another comment. /* This is another comment. It is located in several lines. */

Identifiers and reserved words

An identifier is simply a name. In JavaScript, identifiers act as names of variables and functions, as well as labels for some loops. Identifiers in JavaScript must start with a letter, an underscore (_) or a dollar sign ($). This can be followed by any letters, numbers, underscores, or dollar signs. (A digit cannot be the first character, since this would make it difficult for the interpreter to distinguish identifiers from numbers.) Examples of valid identifiers:

I my_variable_name v13 _myvar $str

For compatibility and ease of editing, only ASCII characters and numbers are typically used to compose identifiers. However, JavaScript allows the use of letters and numbers from the full Unicode character set in identifiers. This allows programmers to name variables in their native languages ​​and use mathematical symbols in them:

Var name = "Alexander"; var Π = 3.14;

JavaScript reserves a number of identifiers that act as keywords for the language itself. These keywords cannot serve as identifiers in programs. JavaScript also reserves some keywords that are not currently part of the language, but which may become part of it in future versions. The table below lists all keywords by category:

Reserved JavaScript Keywords
Category Keywords
Basic identifiers break delete function return typeof
case do if switch var
catch else in this void
continue false instanceof throw while
debugger finally new true with
default for null try
New keywords in the EcmaScript 5 standard class const enum export
extends import super
Reserved words in strict mode (they are available in normal mode) implements let private public yield
interface package protected static

JavaScript is a language and it has its own syntax, which it would be nice to know well.
A JavaScript program consists of sentences that are separated by semicolons.

Sometimes you can miss a semicolon and get away with it, but not always. Therefore, in cases where the end of a sentence is implied, it is better not to forget to put it.

If you inadvertently omit semicolons, spaces, or for some other reason your code does not have a style (and this is important!), then I recommend ESLint.

Offers consist of:

  • Values
  • Operators
  • Expressions
  • Keywords
  • Comments

There are two types of values ​​in JavaScript: variables and literals.

Variables

Variables are used to store values. JavaScript uses a keyword to declare variables var.
We can declare variables in three ways:

  • Using the var keyword. For example, var y = 56;
  • Simply by assigning a value. For example, y = 56;
    But this option is undesirable, since in this case the variable becomes global.
    Why is a global variable bad? If only because, becoming global, it goes out of control of the scope of the function. It can either be changed by other code, or it can itself rewrite the value in someone else’s code
  • Using the let keyword.
    Because In JavaScript (before ECMAScript 6) there is no scope within a block, let was introduced, which allows you to declare variables with a scope - a block.
    For example, if (true) (let y = 4;) console.log(y); // ReferenceError: y is not defined

    You can view current ES6 support.

Literals

Literals are fixed values. These include data types such as null, Boolean, Number, Object, String.
For example, when we declare an array, the part that comes after the equal sign is an array literal.

Var food = ['cheese','potates','cucumber'];

And food is a variable.

Numbers

Numbers are written with or without decimal places.

10.50 1001

In order for the interpreter to understand what the dot means - a method call or a floating point, we need to prompt it in one of the following ways:

1..toString() 1 .toString() // space before dot (1).toString() 1.0.toString()

String

String - text written using double or single quotes.

"I am string“ "And I am string“

Basically, you need to decide which quotes to use and follow your choice as you write your code.

By default, ESLint settings even provide a choice based on the results of which the code will be checked.

Identifiers

The name we give to variables, functions, and properties is called an identifier.
It can only contain alphanumeric characters, "$" and "_".
How is an identifier different from a String?

String is data, and the identifier is part of the code.

Var surname = “Smit”;

“Smit” is uniquely the data - a string literal, while surname is the store for that value.
Note that a hyphen is not allowed in the identifier because it is used for subtraction.

Expressions

An expression is a combination of values, variables, operators that calculates a value.
For example, the expression 3 * 5 calculates 15.
The expression can also contain a variable
x*4
Of course, the values ​​can also be strings.
For example the expression:

"The day" + " is " + "sunny" //calculated into the string "The day is sunny".

Expressions can be divided into those that assign a value to a variable and those that simply calculate values.
First case:

and second:

By the way, as soon as we add a semicolon, we no longer have an expression, but a sentence!

Var x = 56;

Comma for expressions

Comma evaluates both operands and returns the right value.

Var x = 0; var y = (x++, 4); console.log(x); //1 console.log(y); //4

Expressions evaluate to a value and can be written anywhere a value is expected. For example, an argument in a function call or the right side of an assignment.

Each of the following lines contains an expression:

X x + 6 changeArray("a","b")

Wherever js expects a sentence, you can also write expressions.
Such a sentence is called an instruction-expression.

But you can't write a sentence where js assumes an expression. For example, an IF clause cannot become a function argument.

Comparison of sentence and expression

Let's take a look at the IF clause and conditional operator, which is an expression.

Var result; if (x > 0) ( result = "Positive number"; ) else ( result = "Negative number"; )

Equivalent:

Var result = (x > 0 ? "Positive number" : "Negative number");

Between the sign = And ; expression.
To prevent ambiguity in parsing, JS does not allow object literals and function expressions to be used as clauses.

It follows from this that expression sentences should not begin with:

  • curly braces
  • with the function keyword

If an expression begins with one or the other, then it should be written in the context of the expression.
To do this, the expression is placed in parentheses.

Function declaration and function expression

Let's say we want to declare an anonymous function-expression, then we write like this:

(function())(return "ready!")());

Let's look at how this function will differ from a function declaration like

Function getReady() ( return "ready!" )

  • Obviously, the anonymous one has no name. But it may well be, then it will be a named function expression.
  • A function declaration is created by the interpreter before the code is executed, while a function expression is created only during execution.
  • Therefore, expression functions are not available until they are declared.

What if we write it like this?

GetReady(); var getReady = function())( return "ready!"; ) getReady();

In the first line we get an error: TypeError: getReady is not a function
The fifth will display “ready” to us, since the function has already been declared.
This phenomenon is called hoisting, why it occurs is described in the post about.

When learning to write, a person must learn the basics of spelling, grammar and spelling. For example, everyone knows that a sentence begins with capital letter and ends with a period, the text is divided into paragraphs, etc.

Programming languages ​​work in a similar way: in order for a program to work, certain rules must be followed. The set of rules that define the structure of programming languages ​​is called syntax. Many programming languages ​​are built on the same concepts but use different syntax.

This tutorial will introduce you to the basics of syntax and code structuring in JavaScript.

Functionality and readability

Functionality and readability are very important aspects of JavaScript syntax that need to be focused on separately.

Some syntax rules are mandatory for JavaScript code. If they are not met, the console will throw an error and the script will stop running.

Consider this error in the “Hello, World!” program.

// Example of a broken JavaScript program
console.log("Hello, World!"

There is a missing closing bracket at the end, so instead of the line “Hello, World!” the program will return an error:

Uncaught SyntaxError: missing) after argument list

To allow the script to continue running, you must add a closing parenthesis. This is how an error in JavaScript syntax can affect the operation of the program.

Some aspects of JavaScript syntax and formatting come from different perspectives. Simply put, there are stylistic rules and variations that are optional and do not cause errors when running the code. However, there are also many general conventions that are wise to keep track of so that project and code developers are aware of style and syntax updates. Following common conventions will improve the readability of your code.

Consider the following three options for assigning a value to a variable:

const greeting="Hello"; // no whitespace between variable & string
const greeting = "Hello"; //excessive whitespace after assignment
const greeting = "Hello"; // single whitespace between variable & string

All three lines above will work the same. But the third option (greeting = "Hello") is by far the most commonly used and readable way to write code, especially when viewed in the context of a larger program.

It is very important to monitor the integrity and consistency of all program code.

Below we'll look at a few examples to familiarize ourselves with the syntax and structure of JavaScript code.

Whitespace characters

JavaScript whitespace characters are spaces, tabs, and line feeds (this action is performed by the Enter key). As shown earlier, excess white space outside of a line, white space between operators, and other characters are ignored by the JavaScript interpreter. This means that the following three variable assignment examples will have the same result:

const userLocation = "New York City, " + "NY";
const userLocation="New York City, "+"NY";
const userLocation = "New York City, " + "NY";

The userLocation variable will have the value "New York City, NY" regardless of the assignment style for that value. For JavaScript, it doesn't matter what whitespace characters are used.

There is one tried and true rule in writing programs: when you use whitespace, follow the same rules that you use in math or grammar. For example, the line:

easier to read than:

An important exception to this rule is the assignment of multiple variables. Notice the = position in the following example:

const companyName = "MyCompany";
const companyHeadquarters = "New York City";
const companyHandle = "mycompany";

All assignment operators (=) are aligned on a single line using spaces. This type of structure is not used by all code bases, but can improve readability.

Extra line breaks are also ignored in JavaScript. Typically, extra blank lines are inserted above the comment and after the code block.

Round brackets

Keywords such as if, switch, and for usually have spaces before and after parentheses. Consider the following example:

// An example of if statement syntax
if () ( )
// Check math equation and print a string to the console
if(4< 5) {
console.log("4 is less than 5.");
}
// An example of for loop syntax
for () ( )
// Iterate 10 times, printing out each iteration number to the console
for (let i = 0; i<= 10; i++) {
console.log(i);
}

As you can see, the parentheses of the if statement and the loop are separated by spaces on both sides.

When code refers to a function, method, or class, parentheses are written next to the name without a space.

// An example function
function functionName() ()
// Initialize a function to calculate the volume of a cube
function cube(number) (
return Math.pow(number, 3);
}
// Invoke the function
cube(5);

In the above example, cube() is a function and the brackets () will contain parameters or arguments. In this case, the parameters are expressed using number or 5. Writing cube() with a space will also work, but it is almost never used. Writing a function and parentheses together helps you easily associate a function with its arguments.

Semicolon

Just as paragraphs of text are made up of sentences, JavaScript programs are made up of a series of statements called expressions. A period is used at the end of a sentence, and a semicolon (;) is used at the end of a JavaScript expression.

// A single JavaScript statement
const now = new Date();

If two or more expressions are located next to each other, they must be separated by a semicolon.

// Get the current timestamp and print it to the console
const now = new Date(); console.log(now);

If expressions are separated by a newline character, a semicolon is not required.

// Two statements separated by newlines
const now = new Date()
console.log(now)

By general convention, a semicolon is placed after an expression, regardless of newline characters. This reduces the likelihood of errors.

// Two statements separated by newlines and semicolons
const now = new Date();
console.log(now);

Semicolons are also placed between initialization and condition in for loops:

for (initialization; condition; increment) (
// run the loop
}

Semicolons are not placed after if, for, do, while, class, switch, and function statements. These operators are enclosed in curly braces (). Consider the following code:

// Initialize a function to calculate the area of ​​a square
function square(number) (
return Math.pow(number, 2);
}
// Calculate the area of ​​a number greater than 0
if (number > 0) (
square(number);
}

Be careful because not all code enclosed in curly braces does not require a semicolon. Objects are enclosed in curly braces and must end with a semicolon.

// An example object
const objectName = ();
// Initialize triangle object
const triangle = (
type: "right",
angle: 90,
sides: 3,
};

It is a common practice to place semicolons after every JavaScript statement and expression except those ending with curly braces.

Code Structuring

Technically, all of the code in a JavaScript program can be put on one line. But such code is very difficult to read and maintain. Therefore the program is divided into lines.

For example, the if/else statement can be written in one line, or it can be divided:

// Conditional statement written on one line
if (x === 1) ( /* execute code if true */ ) else ( /* execute code if false */ )
// Conditional statement with indentation
if (x === 1) (
// execute code if true
) else (
// execute code if false
}

Please note: any code included in a block is indented. You can indent using two spaces, four spaces or tabs. The choice of indentation method depends solely on personal preference or the recommendations of your organization.

Open parenthesis at the end of the first line - the usual way structuring statements and JavaScript objects. Sometimes the brackets are placed on separate lines:

// Conditional statement with braces on newlines
if (x === 1)
{
// execute code if true
}
else
{
// execute code if false
}

This structure is rarely used in JavaScript, as in other languages.

Nested statements must be separated:

// Initialize a function
function isEqualToOne(x) (
// Check if x is equal to one
if (x === 1) (
// on success, return true
return true;
) else (
return false;
}
}

Proper indentation makes the code readable. The only exception to this rule to keep in mind is that compressed libraries remove all unnecessary symbols to reduce file size.

Identifiers

The names of variables, functions or properties in JavaScript are called identifiers. Identifiers consist of letters and numbers, but they cannot contain characters beyond $ and _ and cannot begin with a number.

Case sensitivity

Names are case sensitive. That is, myVariable and myvariable will be treated as two different variables.

var myVariable = 1;
var myvariable = 2;

By general convention, names are written in camel case: the first word is written with a lowercase letter, but each subsequent word begins with a capital letter. Global variables or constants are written in uppercase and are separated by underscores.

const INSURANCE_RATE = 0.4;

The exception to this rule is class names, where each word typically begins with a capital letter (PascalCase).

// Initialize a class
class ExampleClass (
constructor()
}

To ensure code readability, you must use identifiers consistently across all program files.

Reserved Keywords

Identifiers must also not contain any reserved keywords. Keywords are JavaScript words that have built-in functionality. These include var, if, for and this.

For example, you cannot assign a value to a variable named var.

var var = "Some value";

JavaScript knows the var keyword, so it will throw an error:

SyntaxError: Unexpected token (1:4)

A JavaScript program consists of variables, operators, functions, objects and other language constructs. All of them will be discussed in detail in this textbook. And in this topic I will tell you how they are written in the program code. JavaScript Syntax ordinary and largely coincides with other programming languages.

Spaces and line feed

JavaScript does not require spaces between variables and various statements. But it allows you to put spaces where you need:

Line translation can also be done where it is convenient for you. There is one exception: you cannot create a line break inside text that is in quotation marks. This issue will be discussed in more detail when studying strings. In other cases, you decide for yourself where to translate the line

You can write it like this:

However, I recommend using a semicolon after every statement and function call. First, the absence of a semicolon is not always acceptable, and an error may occur. Secondly, this is a common style of competent coding, and it’s better to get used to it right away. It is advisable to follow the rule: each line must end with a semicolon. The exception is language constructions, which have their own signs. For example, some operators.

When writing your names, for example, when creating variables, character case is also taken into account. company and Company are two different variables.