javscript notes
javscript notes
development. It plays a crucial role in both front-end and back-end development, enabling
dynamic and interactive user experiences.
JavaScript is the world's most popular programming language.
JavaScript is the programming language of the Web.
JavaScript is easy to learn.
JavaScript Can Change HTML Content
JavaScript Can Change HTML Attribute Values
JavaScript Can Change HTML Styles (CSS)
JavaScript Can Hide HTML Elements
JavaScript Can Show HTML Elements
Application of Js
\b Backspace
\f Form Feed
\n New Line
\r Carriage Return
\t Horizontal Tabulator
\v Vertical Tabulator
External JavaScript: create a separate js file and link it to the html file using –
<script src="FILE.JS"></script>
Internal JavaScript: add a block of code in the HTML document itself (specially in
between <head></head or right before closing of </body>– <script>DO
SOMETHING</script>
Inline JavaScript: directly add JavaScript to an HTML element – <input
type="button" value="Test" onclick="FUNCTION()">
JavaScript has 2 main Datatypes
Primitive
o String
o Number
o Integer
o Boolean
o Undefined
Non-Primitive
o RegExp
o Array
o Object
Note: Variables are memory container that has name and used to store value for
the program.
The general rules for constructing names for variables (unique identifiers) are:
Arithmetic Operators
Assignment Operators
Comparison Operators
String Operators
Logical Operators
Bitwise Operators
Ternary Operators
Type Operators
Arithmetic Operator:
Operato Description
r
+ Addition
- Subtraction
* Multiplication
** Exponentiation (ES2016)
/ Division
++ Increment
-- Decrement
Assignment Operator
= x=y x=y
+= x += y x=x+y
-= x -= y x=x-y
*= x *= y x=x*y
/= x /= y x=x/y
%= x %= y x=x%y
**= x **= y x = x ** y
Operato Description
r
== equal to
!= not equal
? ternary operator
Typeof Operator
Operator Description
Bitwise Operator
Date Methods:
Method Description
Events in js
Event Description