Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

# Contributors List

*Names*

1. icodejsx
2. ogbon(Segun Amosu)
3. Solomon Eseme
4. Peter Kasinamunda

46 changes: 46 additions & 0 deletions Events_in_JS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Events in JavaScript


##Key points about events in JavaScript:

- Events are things that happen in the browser, like a click, keypress, mouseover, submit, focus, blur form submit.
- When an event occurs, it fires or is dispatched.
- JavaScript can listen for events using event listeners and handle them using event handlers.
- Events allow JavaScript to react to user interactions and actions in the browser.
- Events are defined and implemented by the browser, not part of the core language.
- Different browsers may implement events differently, though they tend to follow standards.
- You can attach event handlers using:
- Event handler properties
- addEventListener() - the preferred method
- An event listener waits for an event to fire, and an event handler is the function that responds to that event.
- The Event object provides information about the event, like what element fired it.
Event driven architecture refers to a software architecture paradigm where applications react to events or messages emitted from other applications instead of following a sequential flow of execution. This allows for loosely coupled and asynchronous communication between different components of the system.

##In JavaScript, event driven architecture is commonly implemented through:

- DOM events emitted by HTML elements
- The EventEmitter class in Node.js
- Libraries like RxJS that provide Observables
- Frameworks like Redux that follow a publish-subscribe model

Some key concepts of event driven architecture in JavaScript are:

## Subjects and Observers

- Subjects (or event emitters) are objects that emit events. This includes HTML elements, EventEmitter instances, Observables, etc.
- Observers (or event listeners) are functions that react to events emitted by subjects. This includes event listeners registered using `addEventListener()`, `.on()` handlers, Observable subscriptions, etc.
- Observers "observe" or listen for events from subjects and perform actions when those events occur.

## Events

- Events are notifications emitted by subjects when something of interest occurs.
- Events typically have a name (like "click" or "change") and optionally some data associated with them.
- Observers register themselves with subjects to listen for specific events using names.

## Event Loop

- In JavaScript, the event loop drives the execution of event handlers in response to events.
- When an event is emitted, it's added to the event queue.
- The event loop polls the event queue and executes the associated event handlers.
- This asynchronous, reactive nature allows for decoupled and parallel execution of event handlers.

42 changes: 42 additions & 0 deletions Lexical Scope.md
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
# Lexical Scope

## Description
First assignment on Lexical Scope

----------------


## What is Lexical Scope?

Lexical scope refers to the region of a program where a variable is visible and accessible. In other words, it refers to the area of code where a variable gets its meaning.

Variables in JavaScript have one of two scopes:

* Global scope: Variables defined outside of a function are accessible anywhere in your JavaScript code. They are said to have global scope.
* Local scope: Variables defined inside a function are accessible only within that function. They are said to have local scope.

Lexical scope in JavaScript is determined statically, based on the location where a variable is declared. This is in contrast to dynamic scope, where the scope is determined based on the call stack.

Some key points about lexical scope:

- The scope of a variable is determined by where it is declared, not where it is used.
- Inner functions have access to variables declared in outer functions, but not vice versa. This is known as closures.
- Variables declared with `let` and `const` have block scope and are only accessible within that block.
- Variables declared with `var` have function scope and are accessible within the entire function.

Here is an example:

function outer() {
let message = "Hello";

function inner() {
console.log(message);
}

inner();
}

outer(); // Prints "Hello"

Here, `message` is defined within the scope of the `outer()` function. But the inner `inner()` function has access to it through closure, since it is defined within the lexical scope of `outer()`.

Hope this explanation helps! Let me know if you have any other questions.