JAVA
Script
JavaScript is a programming language of Html and its a scripting language.
JavaScript doesn’t compile meaning it doesn’t translate to other languages
before executing.It transpile.
JavaScript is language that function from the front end. It is non
blocking meaning it doesn’t refresh.
Variables (JavaScript)
In JavaScript, a variable contains
a value, such as "hello" . When you use the variable, you refer to
the data it represents.
e.g var room =26;
var name = “Stanley”
You use variables to store,
retrieve, and manipulate values that appear in your code. Try to give your
variables meaningful names to make it easy for other people to understand what
your code does.
Declaring Variables
The first time a variable appears in
your script is its declaration. So you can refer to it later on in your
script. You should declare variables before using them. You do this using Var
keyword; see the example above.
Naming Variables
·
Do
not give your variable a key word .
·
Variable
must not contain spaces.
·
Can
not start with numbers but can end with
numbers
Eg var 23long
------à this is wrong
var long23 -------à this is correct.
·
Variable
are case-sensitive.
·
You
can use a dash or underscore ( - or _
)at the beginning or at the middle of a variable.
Eg var
sta_nlo
var _stanlo
·
You
can name a variable using camelcase.
Eg var
firstName
Variables should not start with a Cpital letter but use camelcase
instead.
VARIABLE DATA TYPES
1. Number Data Type: this is divided into 2
Ø integer values
Ø floating-point values
Integer Values
Integer values can be
positive whole numbers, negative whole numbers, and 0. They can be represented
in base 10 (decimal), base 16 (hexadecimal), and base 8 (octal). Most numbers
in JavaScript are written in decimal.
Floating-point Values
Floating-point values
can be whole numbers with a decimal portion. Additionally, they can be
expressed in scientific notation. That is, an uppercase or lowercase
"e" is used to represent "ten to the power of".
A number
that contains a decimal point and that has a single "0" before the
decimal point is interpreted as a decimal floating-point number.
String
Data Type
You use the string data
type to represent text in JavaScript. You include string literals in your
scripts by enclosing them in single or double quotation marks. Double quotation
marks can be contained in strings surrounded by single quotation marks, and
single quotation marks can be contained in strings surrounded by double
quotation marks. The following are examples of strings:
eg
"Happy am I; from care I'm free!"
'"Atlast, I’m free!" roared the
technician.'
"45"
'c'
Boolean Data Type
Whereas the string and
number data types can have a virtually unlimited number of different values,
the Boolean data type can only have two. They are the literals
true and false. A Boolean value is a truth-value: it
specifies whether the condition is true or not.
JavaScript Operators
·
+ :addition
·
_ :subtraction
·
X
:multiplication
·
/ :division
·
< :less than
·
> :greater than
·
% (
modulo):
This is used to check if a number is even [ this always get the remainder in calculation] e.g 10%5= 0
This is used to check if a number is even [ this always get the remainder in calculation] e.g 10%5= 0
·
<= :less or equal to
·
>= :greater
or equal to
·
= : this
is used to assign a value from the right to your left
·
== :this mean equal to
·
=== :this mean you tell computer to check if they
are of the same type (compare).
·
!= :not
equal.
·
!== :not
equal value or not equal type
Conditional Statements
These are statements
used to perform different actions for different decisions.
They are as
follow
IF Statement
ELSE Statement
ELSE IF Statement
No comments:
Post a Comment