js plan
js plan
JavaScript was created by Brendan Eich in 1995 during his time at Netscape Communications. It
was inspired by Java, Scheme and Self.
Internal JS – External Js
Declaring variables with var (non-block scope), let, and const – They are the ones that holds the
data
Changing types
ParseInt, ParseFloat
String
Comparison operators - (>, <, >=, <=, ==, ===, !==, !=)
String Manipulation -
Slice - It allows you to extract a portion of an array or string without modifying the original data.
Split - used to divide a string into an array of substrings based on a specified separator.
Substring - used to extract a portion of a string based on specified start and end indexes.
Function scope
- Modern way
Array methods:
Iterating over an array means going through each element in the array one by one and
performing some operation or action on each element.
For loop – get the data by looping and based the array index on the current loop
Higher-order functions
A higher-order function is a special kind of function that can either accept other
functions as inputs or produce functions as outputs.
forEach(): Calls a provided function once for each element in an array, but doesn't
create a new array.
map(): Creates a new array by applying a function to each element of an existing array.
filter(): Creates a new array containing elements that pass a specified test (provided as a
function).
slice - returns a shallow copy of a portion of an array into a new array object selected
from start to end (end not included) where start and end represent the index of items in
that array. The original array will not be modified.
sort(): Sorts the elements of an array . (use reverse for desc) (String based)
every(): Checks if all elements in an array pass a test (provided as a function). It returns a
Boolean value.
some(): Checks if at least one element in an array passes a test ( It doesn't modify the
array.).
find(): Returns the first element in an array that passes a specified test (provided as a
function).
findIndex(): Returns the index of the first element in an array that passes a specified test
(provided as a function).
querySelector - returns the first Element within the document that matches the
specified selector, or group of selectors.
The DOM can change almost everything about HTML element such as:
Eventlisteners / Events
Event listeners are used to attach functions (event handlers) to specific events, allowing
you to execute custom code when those events occur.
Synchronous – Each task is completed before the next one starts, creating a clear and
predictable flow. However, if a task takes a long time to finish, it can block the entire program's
execution, leading to potential responsiveness issues.
Asynchronous - programming is a way of executing tasks without waiting for the previous task
to complete. It enables other tasks to continue running while certain operations are being
performed.
1. SetTimeout
2. Set Interval / Clear Interval
3. Event handlers
4. File uploading
5. Ajax
Callback hell - The situation where callbacks are nested within other callbacks several
levels deep, potentially making it difficult to understand and maintain the code.
Promises - represents the eventual completion (or failure) of an asynchronous operation and its
resulting value.
async await
What is Ajax?
JSON OVERVIEW
Activity: Try to submit the data from the registration form going to PHP and displaying it back to a
table