From b0bbbfbc789f1fb97d8e5bc40e8745842a85c7e6 Mon Sep 17 00:00:00 2001 From: Nathanael Oluwaseyi Date: Tue, 14 Nov 2023 22:34:18 +0100 Subject: [PATCH 1/4] Add name to Contributors.md --- Contributors.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contributors.md b/Contributors.md index a9e9ede..46438c1 100644 --- a/Contributors.md +++ b/Contributors.md @@ -5,4 +5,4 @@ 1. icodejsx 2. ogbon(Segun Amosu) 3. Solomon Eseme - +4. Oluwaseyi Oluwadare From 097ca2cef8fe2cc9c3f72bd53eb944c39ab3ea30 Mon Sep 17 00:00:00 2001 From: Nathanael Oluwaseyi Date: Tue, 14 Nov 2023 23:04:11 +0100 Subject: [PATCH 2/4] Assignment on git commands --- git_commands.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 git_commands.md diff --git a/git_commands.md b/git_commands.md new file mode 100644 index 0000000..2689457 --- /dev/null +++ b/git_commands.md @@ -0,0 +1,14 @@ +# Git commands + + +git add: Stages changes to be commited. +git commit: Makes record of changes to the repository. +git push: Transfers commited changes from local repository to remote repository. +git init: Initializes a new Git repository in the current directory or turns an existing directory into a Git repository. +git status: Shows the current state of working directory as well as changes to tracked and untracked files. +git branch: Lists or creates branches in the repository. +git checkout: switches branches. +git remote: Connects to remote repositories. +git clone: Makes copy of an existing repository from a remote source to local repository. +git reset: Unstages staged changes or undo changes. +git log: Shows history of changes made in the repository. \ No newline at end of file From ab2a287620e517db82b63a8ac893985065c6f5a0 Mon Sep 17 00:00:00 2001 From: Nathanael Oluwaseyi Date: Wed, 15 Nov 2023 00:06:12 +0100 Subject: [PATCH 3/4] Lexical scope assignment --- lexicalScope.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lexicalScope.md diff --git a/lexicalScope.md b/lexicalScope.md new file mode 100644 index 0000000..9ae0fef --- /dev/null +++ b/lexicalScope.md @@ -0,0 +1,25 @@ +# Lexical Scope + +In JavaScript lexical scope is a fundamental concept which refers to how variable names are accessed and resolved in nested functions, whereby the region or domain where a variable is sorted using where it can be found within the source code. Simply put lexical scope means the scope of a variables is defined by the placement of variables and blocks in the code. + +A function nested inside another function in JavaScript forms a lexical scope. This nested function is in such a way that the inner function can access the variables of its outer function, which is not determined by the way the functions are called or executed but rather by how the functions are positioned within the code. + + +A simple example to illustrate lexical scope: + +function outer() { + let outerVar = 'I am from outer'; + + function inner() { + let innerVar = 'I am from inner'; + console.log(outerVar); // Inner function has access to outerVar + console.log(innerVar); + } + + inner(); +} + +outer(); + + +As shown in this example, the concept of lexical scoping makes it feasible for the "inner" function to have access to both "outerVar" and its own "innerVar" in such a way that the inner function sort of have recall of its memory of the scope in which it was created, having access to variables in that scope even when it is called outside the scope. \ No newline at end of file From 536b8fa0c9e400280e502d49d3e51c3fb2c74b58 Mon Sep 17 00:00:00 2001 From: Nathanael Oluwaseyi Date: Wed, 15 Nov 2023 00:51:15 +0100 Subject: [PATCH 4/4] node.js backend engineering events --- backendEvents.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 backendEvents.md diff --git a/backendEvents.md b/backendEvents.md new file mode 100644 index 0000000..7a79dca --- /dev/null +++ b/backendEvents.md @@ -0,0 +1,40 @@ +# Events in node.js backendengineering + + +Events as regards to node.js backend engineering refer to the major aspect of software design style where program is designed to respond to events -user actions or messages from other programs -as they occur instead of following a predeterminded sequence of steps. In node.js events are used in the efficient handling of asynchronous operations whereby a program doesn't have to wait for a particular task to finish before moving on, allowing a program to continue with the processing of other events while waiting for time consuming task to finish thereby making Node.js well-suited for scalable and high-performance backend development. + + + +Here are the components related to events in node.js: + +- EventEmitter: which are the objects in node.js that emit events. It is a core module in Node.js that provides an implementation of the event-driven programming parttern. + + +- Event Loop: This handles the perpetual listening for events such as those triggered by various sources: incoming HTTP requests, custom events within the application and file system operations -and executes callbacks due to those events. + + +- Event Handlers: These are functions that are executed in response to a specific event occurring. + + +- Event Emission: Events are emitted using the emit method. When an event occurs, the emit method notifies all registered listeners by invoking their associated callbacks. + + + +Here's a simple example illustrating the use of events in Node.js: + + +const EventEmitter = require('events'); + +// Create an instance of EventEmitter +const myEmitter = new EventEmitter(); + +// Register an event handler +myEmitter.on('customEvent', (data) => { + console.log('Event occurred with data:', data); +}); + +// Emit the custom event +myEmitter.emit('customEvent', { message: 'Hello, Node.js!' }); + + +In this example, myEmitter is an instance of EventEmitter. The on method is used to register an event handler for the custom event named 'customEvent'. When the event is emitted using emit, the associated handler is invoked, and the message is logged. \ No newline at end of file