Variables and operators in Java

V

In a script (or program), constant data and variable data are used that change values ​​during program execution. These data are called variables. Variable = the name of a location in the computer’s memory used to store data. The easiest way to use and refer to such a variable date is to name it. The variable name allows access to its value as well as changing the value if necessary.

You can create a variable and assign it a value by two methods:
– With the var var statement name = value
– Without the statement, the name = value
– Where ‘name’ is the name of the variable and ‘value’ is the value that we assign.

Types of variables – Unlike other languages ​​(such as Pascal or C), JavaScript does not have fixed data types, meaning it can change the type of a variable within the script, it can recognize itself when the data is of the “string” type, numeric or another type. The lifetime of a variable – A variable written in a function is a local variable, its value being recognized only within that function when the variable function output is destroyed. Thus, another function can declare and use a variable with the same name, JS (Java Script) treats the two variables as different. You can declare variables, other than any function, to be used by all functions, they are called global variables and are valid from the loading of the web page to the closing in any JS script.

There is the possibility to declare and initialize several variables or constants of the same type in a single instruction as follows:
Variable type1 [= value1], variable2 [= value2], …;
The Convention naming variables in Java includes, among others, the following criteria:
-the final variables (constants) are written in capital letters;
– the variables that are not constant are written as follows: the first letter and if the variable name is made up of several lexical atoms, then the first letters of the other atoms are capitalized.

Depending on where the variables are declared, they fall into the following categories:
– Member variables declared within a class visible for all methods of that class and for other classes according to their level of access (see “Statement of member variables”).
– Parameters of methods, only visible in that method.
– Local variables declared in a method, visible only in that method.
– Local variables, declared in a block of code, only visible in that block.
– Parameters from exception handling.

Operators:
In order to work with the data entered in a script and to manipulate the values ​​of the variables, operators are used. Operators are symbols and identifiers that determine how data is modified and how a combination of expressions and variables is evaluated.

JavaScript recognizes:
binary operators – that require the existence of two operands in expression.
unary operators – who only need an operand.

Operators are of several types:

– Arithmetic operators
– Awarding Operators
– Comparators
– Logical operators (also called booleans)
– Operators for strings
– Operators typeof
– Conditional operators
– Operators for functions
– Operators for data structures

Recent Posts

Archives

Categories