Javascript Notes
Javascript Notes
JAVASCRIPT SESSION 1
https://transcripts.gotomeeting.com/#/s/
28006b79d614b7ec8b5e944b4e86f22e9cd008b13ed5cf301e4fb724068d0c7f
Datatypes
Variables
- We cannot write direct type name we use var, let or const keyword to declare a variable
- With var keyword
o We get global & function scope only not block scope
JAVASCRIPT SESSION 2
https://transcripts.gotomeeting.com/#/s/
51fd54b948e1a6b4d932a23c0df15693d180114935278a288c7b6ec780c311e0
To apply javascript on html page
- 1. Inline javascript
o Using html attributes events name starts with on-
- 2. Internal javascript
o Using script tag
o It is always good to load javascript as late as possible
- 3. External javascript
o Using a separate javascript file
Datatype
Number type
Boolean type
String type
JAVASCRIPT SESSION 3
https://transcripts.gotomeeting.com/#/s/
e3c3f90a7085536a7e784fc7a38182c310d104aaf565928b157d79b8e1788770
String functions
Conditional statements
If
If else
Ternary operator
Switch
Array
- Mutator functions – function changes original array itself like push(), unshift(), pop(), shift(),
splice()
- Reverse(), sort(), filter()
Looping statements
- While
- Do while
- For loop
- Advanced for loop
JAVASCRIPT SESSION 4
https://transcripts.gotomeeting.com/#/s/
e77661c7852a3c2d5fa7f82b49637e0da687c151e08e8a4f2d3d1afac6f10341
Function
JAVASCRIPT SESSION 5
https://transcripts.gotomeeting.com/#/s/
6ca4db2ebfd407e5c548194713760b8e6afb59f1037f5450a7a077579f17d0e8
Timing events
- setInterval
- clearInterval
- setTimeout
- clearTimeout
JAVASCRIPT SESSION 6
https://transcripts.gotomeeting.com/#/s/
018a72f2f81446dce608dd2653e81b186c5949c21c4d28f4eced1db8244a1e7d
DOM
- value
- innerText
- innerHTML
JAVASCRIPT SESSION 7
https://transcripts.gotomeeting.com/#/s/
b34a78ae7163d284d1299e1049958d09eb91a3c553a04a4c3d6e3507d51a8a06
Events
- any action performed on browser page, if we want to track or execute any javascript code
- we have key events, mouse events
- mouse events
o mouse over
o mouse out
o mouse move
o mouse down
o mouse up
o mouse click
o mouse double click
o context menu – to identify right click
- to register event we have different ways
o using html attribute
o using DOM object property
o using special methods like addEventListener, removeEventListener
- event bubbling
o if we have nested html elements, all elements assigned with events in this case
when inner element events gets triggered, it fires all events from inner to outer
elements
o events gets bubbled from inner to outer element
o preventing event bubbling
▪ stopPropagation()
- event capturing
o opposite to event bubbling
o events gets fired from outer to inner element
- event object
o it contains information about element on which event happened
o event.which property to know which button is clicked on mouse
▪ left button = 1
▪ middle button = 2
▪ right button = 3
- Preventing browser default actions
o Like right click
o Task
▪ Prevent copying content from page
▪ Prevent paste in textbox or textarea
JAVASCRIPT SESSION 8
https://transcripts.gotomeeting.com/#/s/
abf5a242bb53a9a06d1535b918936b3a9ce17465add36d6d68e5af6d26b3fbec
Window.open()
Regular expression
- We use regular expression to validate patterns
- Pattern like email, strong password, pin code, mobile number etc..
JAVASCRIPT SESSION 9
https://transcripts.gotomeeting.com/#/s/
7bb703b50a72fdf5d18fb6b6749929f11e0120f37405eff86ef28ac94b02d6e8
Regular expression:
To check pattern
Visit:
https://regexlearn.com/learn
https://regexone.com