From ff3fc72b052b2a9beeb40545c6f9cf6148177732 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 8 Nov 2023 11:11:55 -0800 Subject: [PATCH 1/3] Add my name to Contributors.md --- Contributors.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Contributors.md b/Contributors.md index eaab6fe..babce3d 100644 --- a/Contributors.md +++ b/Contributors.md @@ -1,3 +1,4 @@ + # Contributors List *Names* @@ -5,4 +6,4 @@ 1.icodejsx 2.ogbon(Segun Amosu) - +3.Peter Kasinamunda From 1f3379920510ff7a63a1486309519d83d998c3f4 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 13 Nov 2023 03:27:30 -0800 Subject: [PATCH 2/3] adding assignments --- Events_in_JS | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Lexical Scope.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 Events_in_JS diff --git a/Events_in_JS b/Events_in_JS new file mode 100644 index 0000000..6dc4ad2 --- /dev/null +++ b/Events_in_JS @@ -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. + diff --git a/Lexical Scope.md b/Lexical Scope.md index b73a209..88cb3c2 100644 --- a/Lexical Scope.md +++ b/Lexical Scope.md @@ -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. From be603f8852f6a3878d78e02ff9757c8a9ee2921a Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 13 Nov 2023 03:33:57 -0800 Subject: [PATCH 3/3] adding assignments --- Events_in_JS => Events_in_JS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Events_in_JS => Events_in_JS.md (100%) diff --git a/Events_in_JS b/Events_in_JS.md similarity index 100% rename from Events_in_JS rename to Events_in_JS.md