0% found this document useful (0 votes)
30 views10 pages

JavaScript Variables, Datatypes, and Operators

The document provides an overview of JavaScript, covering key concepts such as variables, data types, operators, and functions. It explains the use of 'var', 'let', and 'const' for variable declaration, as well as the differences between primitive and non-primitive data types. Additionally, it includes examples of various operators and their usage in JavaScript programming.

Uploaded by

schnkumaran429
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views10 pages

JavaScript Variables, Datatypes, and Operators

The document provides an overview of JavaScript, covering key concepts such as variables, data types, operators, and functions. It explains the use of 'var', 'let', and 'const' for variable declaration, as well as the differences between primitive and non-primitive data types. Additionally, it includes examples of various operators and their usage in JavaScript programming.

Uploaded by

schnkumaran429
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Tarascript

Java script
.
1 Variables , Datatypes and
Operators

Variables

data box Javascript


*
storage in

Example
let num = 5; Variable

data
Three to declore a variable
ways

*
using var

* let
using
* const
using

Vari

The var
keyword was used in
Javascript from 1995-2015
.

It is also used to declare


globe scope variables

Example : Var variablename =


value of var ;

let :

The let used to decore blockscoped (local variable)


keyword is

variable . The variable that a re declared inside 29 .

let variable name = value of var;

consti

It is used to
define constant variable to store constant variables

be later in the
can't
reassigned or
changed program
.
const variable name = value of van;
Rules of declaring Variable

Start with
* a letter (a-z) or (A-2) ,
underscore ( )
_
or dollar (1)
* Numbers can be used
after first letter (0-a)
* case sensitive .

Javascript Datatypes -
:

Tuppes of Datatypes
* Primitive
* Non Primitive

Primitive Datatupes

The Javascript
primitive datatypes in a re

Inside "noblesinglenote' bea


* string -

* number -

Numbers let num = 9;

# Boolean True/FALSE let check false


=
;
-

*
Undefined Not initialized let
-

num ;

* NULL No value
-

Non-primitive datatypes
Instance
* Object -

through which we can access

methods
*
Array of value
of datatype
-

group same

*
Reg Exp -

Regular Expression

OBJECT

const student [ firstname


:

: 'ram" ,
lastname : 'NULL'
class : 1053 ;
Operators

Arithmetic Operators :

* Addition * Subtraction *
Multiplication Division # Modulus

* Increment * Decrement

Logical Operators
* AND (00) * Or (11) * Not (1)

Comparison Operators
!== lesser
* =
equal to * notequal type * >

* ! = notequal to * > Greate * >= Greater or equal


* <= lesser or equal

Bitwise Operators
* Bitwise AND ( &) 0 & I I O

* Bitwise or (1) O 11 =
I

* Bitwise XOR (1) 0 -1


I I

* Btwise NOT (f) -I =


0

* Left shift (() 2) 1 =


0010
-
> 0 , 00 = 4

*
Rightshift (x) 2x1
=
0010
-
> 0001 = 1

Assignment Operators :
1) =
2) += 3) x =
4)) =
5) %=

Miscellaneous Operators
:

1) Ternary Operator · var = (condition) ? true : False ;

2) Type of :
returns datatype of variable

3) Instance of : check if the object is instance of

given type
Question : Statement Expressions How a statement is typed/rules/features

Keywords : Var return

let
try
coust if

function switch

Expressions : Combination of Operators and Operands

Comments : // for single line

/k more than one line

Javascript Output :
writing into HTML elements inner HTML
.

writing into HTML Output document. write()

into alertbox window. Alerts


writing an

writing into browser console console -

log()

Javascript functions : Block of code designed to


perform a
particular
task

May include
parameters

Syntase : function functionname (parameter)


&
//code
4
Example

(script)
function msg()
[
alert ("hello") ;
Y

/script)
(input type : "button" onclick =

"msg()" value =
"Callfunctionity

Function with
arguments

< script)
function geteube (number)
E
alert (number number) ;
Y

EscriptY
< form

Linput type - "button" value : "Click" Onclick =


"getcubeln!
17

(Horm)

Return value :

[script]
function getinfo() [

return "Hello" ;

4
script]
<
script document . write (getinfo()) ;
/script)
document get ElementByld ("Id name") inner Ham value ;
=
.

External script

L head)

(script type =
"text/javascript" suc =
"message js
.

/head)

Arrays
Syntac :

const
=
[item 2 3 7
arrayname
=

,
.
,

new Keyword to Assign value

["TATA" "BMWD;
const
Array
=
cars new
,

last element
Array popl) -
remove

Array ·
Shitl) =
remove first element and move others to lower

unshift() element at other


Array .
= add new
beginning and more

to
upper

concotly-merge

Array length of
length return Array
=

Array push () = add elements


-

Sort()
·
=
sort

· reverse () =
reverse
UPC
Css-Css its
and
types-inline ,
internal Extern

Combining selectors
Styling texte and hyperlinks
Y
Layouts flexe and
grid
Defining colour
Wet
design rules and
frameworks ,
Sass X

Javascript-Operators datatypes
and

Javascript functions
Javascript Arrays and its operations

String and methods

looping and conditional statements

External CSS

< link rel -


"stylesheet" type = "feet/ess" Gret =

"style is
.

Selector

Element Element Class · classname

Element cassname
: inside Element

ID #idname

Universal : *

Element Hidname (inside element)

Grouping selector : Element ,


Element ,
Element
descendant (space) All
descending Elements
-

div p
23 All inside dir.
para

child-(x) All children elements

div >p 23 No nested


pare
will be transformed.

Adjacent Sibling -

(A) directly next to it

General sibling (n) select every tag next to the specified.


-

Coloring RGB RGBA HSL HSLA Names Hescode .

(0-1)
0 -
2550 2850-255
-
(o 1)
-

/
·

(o 310)
=

% # 000000 -

#FFFFF

black-white

Float Flexbox Grid

Hyperlink * a :
link
* a: visited

* a hover
* a : active
Text : * text-color -
color

* text aligh text-align left right


,
, center

↓ text decoration text-decoration


underline

overline

line through
to text transformation

text-transformation

capitalize
uppercase
lowercase
* text indentation

text-indentation
before text
space
values in pe, m , pt

* word-spacing
word-spacing : 5px ;

* Letter spacing
letter spacing :
Spre ;

* Text direction direction :

rf

Itr

* Line height line-height :


px ;

* Text shadow feet-shadow ic , y, z color

# fort
family font-family : "Times New Roman" ;

You might also like