Java: Java Programming For Beginners a simple Start To Java Programming (Written By a software Engineer)


Download 0.82 Mb.
Pdf ko'rish
bet86/95
Sana09.01.2022
Hajmi0.82 Mb.
#261112
1   ...   82   83   84   85   86   87   88   89   ...   95
Bog'liq
Java Programming For Beginners - A Simple Start to Java Programming ( PDFDrive )

Writing Code in JavaScript
Any statement followed by a semicolon is referred to as a statement. This statement may
or may not produce a value unlike expressions, which must inadvertently produce a value.
Variables
Manipulation of data is performed with the help of variables. Data is stored in the memory


and  a  named  reference  to  this  memory  location  is  called  a  variable.  Any  identifier  is
declared  as  a  variable  by  preceding  it  with  a  keyword  var.  A  sample  declaration  of  a
variable is:
var result;
This statement declares a variable result. You may also define the variable as you declare
it using a statement like this:
var result = 0;
or
var result = 23*4+6;
Certain rules have to be followed while naming variables. These rules are as follows:
A variable name can be a combination of numbers and characters.
A variable name cannot start with a number.
The only special characters allowed in variable names is underscore (_) and dollar
sign($).
There  should  not  be  any  whitespace  in  the  variable  name.  For  example,  ‘result
value’ is not allowed.
JavaScript keywords are reserved and cannot be used.
Please note that JavaScript, unlike HTML is case sensitive. Therefore VAL and val are two
different variables. Also, it is recommended that the variable name should be such that it
describes the purpose for which it is being used. For example, if we name a variable result,
it is evident that this variable will contain the result value computed by the code.
Another convention used in JavaScript is to name variables such that the first letter of the
variable name is lowercase. However, every subsequent word in variable name starts with
a capital letter. An example of this is the variable name, arrayResult. Besides this, the use


of underscore and dollar sign is discouraged. However, they are used in jQuery objects.

Download 0.82 Mb.

Do'stlaringiz bilan baham:
1   ...   82   83   84   85   86   87   88   89   ...   95




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling