Sunday, February 1, 2026

Full Stack Development- Class 5 - Arrays

 JavaScript arrays are ordered, zero-indexed collections of values stored under a single variable name. They are a fundamental data structure, enabling efficient storage and manipulation of lists of data. Arrays in JavaScript are dynamic, meaning they can resize and hold a mix of different data types. 

Key Characteristics
  • Ordered and Zero-Indexed: Elements are stored in a specific order and accessed using a numeric index, starting at 0 for the first element.
  • Dynamic Size: Arrays can grow or shrink as elements are added or removed, without needing to define a fixed size upfront.
  • Heterogeneous: A single array can contain different data types, such as strings, numbers, objects, and even other arrays.
  • Objects: Arrays are special types of objects in JavaScript; the typeof operator returns "object" for arrays.
  • Shallow Copies: Built-in array-copy operations create shallow copies, meaning nested objects within the array still refer to the same object in memory. 
Creating Arrays
The most common and preferred way to create an array is using array literals (square brackets). 
// Creating an empty array
let emptyArray = [];
// Creating an array with initial values
const fruits = ["Banana", "Orange", "Apple", "Mango"];
// Output: ["Banana", "Orange", "Apple", "Mango"]
Common Operations and Methods
JavaScript provides numerous built-in methods for array manipulation. Some of the most frequently used methods are: 
Accessing Elements: Use the index in square brackets to access a specific element:
let firstFruit = fruits[0]; // "Banana"
let lastFruit = fruits[fruits.length - 1]; // "Mango"
  • Adding Elements:
    • push(): Adds one or more elements to the end of an array.
    • unshift(): Adds one or more elements to the beginning of an array.
  • Removing Elements:
    • pop(): Removes the last element from an array.
    • shift(): Removes the first element from an array.
    • splice(): A versatile method for adding/removing elements at any specific position.
  • Iterating: Use methods like forEach()map(), or filter(), or standard loops (forfor...of) to process array elements.
  • Combining Arrays: concat() merges two or more arrays into a new array without modifying the originals.
  • Sorting and Searching:
    • sort(): Sorts the elements of an array in place.
    • find(): Returns the value of the first element that satisfies a provided testing function.
    • includes(): Checks if an array contains a certain element and returns a boolean. 
Example of Javascript Arrays:

<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>

<p id="demo"></p>

<script>
const cars = ["Saab", "Volvo", "BMW"];
document.getElementById("demo").innerHTML = cars;
</script>

</body>
</html>

Creating Arrays Using the JavaScript Keyword new
const cars = new Array("Saab""Volvo""BMW");

Changing an Array Element

This statement changes the value of the first element in cars:

cars[0] = "Opel";

Converting an Array to a String

The JavaScript method toString() converts an array to a string of (comma separated) array values.

Arrays are Objects

Arrays are a special type of objects. The typeof operator in JavaScript returns "object" for arrays.

But, JavaScript arrays are best described as arrays.

Arrays use numbers to access its "elements". In this example, person[0] returns John:

const person = ["John""Doe"46];

Array Methods:

Basic Array Methods(from w3schools.com)

Array length
Array toString()
Array at()
Array join()
Array pop()
Array push()
Array shift()
Array unshift()
Array isArray()
Array delete()
Array concat()
Array copyWithin()
Array flat()
Array slice()
Array splice()
Array toSpliced()

Full Stack Development- Class 4 - Variables, Data Types

 JavaScript uses variables as containers to store data values and is a dynamically typed language, meaning variable types are determined at runtime. Data is categorized into primitive and non-primitive types. 

Variables in JavaScript
Variables are declared using one of three keywords, each with different scoping and reassignment rules: 
  • var: Function-scoped (or globally-scoped) and can be updated and re-declared within the same scope. It is generally recommended to avoid var in modern JavaScript development in favor of let and const.
  • let: Block-scoped and can be updated but not re-declared within the same scope. This is the preferred way to declare variables whose values may change.
  • const: Block-scoped and creates a read-only "constant" that cannot be reassigned after its initial declaration. It must be initialized when declared. Note that while the variable itself cannot be reassigned, the properties of an object or elements of an array assigned to a const variable can still be modified. 

    Naming Rules
    • Names must begin with a letter, underscore (_), or dollar sign ($).
    • Names cannot begin with a number.
    • Names are case-sensitive (Boy and boy are different variables).
    • Reserved keywords (like ifforletconst) cannot be used as variable names. 


    Data Types in JavaScript
    JavaScript has eight data types, which are divided into two main categories: 
    Primitive Data Types
    These represent single, immutable values. 
    • String: Represents textual data, enclosed in single quotes ('...'), double quotes ("..."), or backticks (`...`).
    • Number: Represents numeric values, including integers and floating-point numbers. It also includes special values like Infinity and NaN (Not-a-Number).
    • Boolean: Represents a logical entity with only two possible values: true or false.
    • Undefined: A variable that has been declared but not assigned a value automatically has the value undefined.
    • Null: Represents an intentional absence of any object value. It is a special value that a programmer explicitly assigns.
    • Symbol: A unique and immutable primitive value, often used as an object key to avoid naming conflicts.
    • BigInt: Represents integers of arbitrary precision, larger than the maximum value a Number can safely hold. 

    Non-Primitive Data Type (Reference Type)
    The Object type is the only non-primitive type and is used for more complex data structures. When assigned to a variable, the variable holds a reference to the object's memory location, not the value itself.
    • Object: Collections of key-value pairs used to store structured data. E.g., let person = { name: "John", age: 30 };.
    • Array: A specialized type of object used to store ordered lists of values, accessed by an index (starting from zero). E.g., let fruits = ["Apple", "Banana"];.
    • Function: Functions are first-class objects in JavaScript and can be stored in variables, passed as arguments, and returned from other functions. 

    Full Stack Development- Class 2 - Javascript Instructions

     Javascript Instructions

    Key Components of JavaScript Instructions

    JavaScript instructions are composed of several key elements:

    Syntax: This refers to the rules that must be followed for the code to work correctly. Key rules include using keywords correctly, employing proper variable naming conventions, and utilizing semicolons to separate statements (though they are often optional, they are recommended for clarity).

    Keywords: These are reserved words with specific meanings that identify a JavaScript action to be performed, such as var, let, const, if, for, function, and return.

    Values and Variables: Instructions often involve working with data. Variables (declared with var, let, or const) are used to store data values.

    Operators: These are special symbols used to perform operations on values and variables, such as arithmetic (+, -, *, /), assignment (=, +=), comparison (==, ===, >), and logical (&&, ||) operators.

    Functions: These are reusable blocks of code that perform a specific task. They can be defined and then called (executed) when needed.

    Control Flow: This determines the order in which statements are executed. It includes conditional statements (if/else, switch) and loops (for, while) that allow code to make decisions and repeat actions.

    Objects and Arrays: JavaScript works extensively with objects (collections of properties and methods) and arrays (ordered lists of values).

    Examples of JavaScript Instructions:

    //Declaring a variable
    let greeting = "Hello, world!";
    //Comments: 
    // A single-line comment
    /*
       A multi-line comment
    */
    
    // Declare a constant variable
    const greeting = "Hello, World!"; 
    
    // Declare a variable using 'let'
    let number = 10;
    
    // Use a built-in function to display an alert box
    alert(greeting); 
    
    // Use DOM manipulation to change the content of an HTML element with id="demo"
    document.getElementById("demo").innerHTML = "I have " + number + " items.";
    Variables can be declared by two ways:
    var i = 5; 
    let j = 7;
    Here i is inferred to be an integer. and its function scoped if its declared inside the 
    function. Otherwise if its declared globally its having global scope. 
    Redeclaration allowed in the same scope.
    Whereas let is a keyword that allows declaration of block scoped variables. These can
    be hoisted, and result in ReferenceError if accessed before declaration.
    While var declarations are hoisted and initialized as undefinedlet and const are hoisted but remain uninitialized in a "Temporal Dead Zone," causing errors if accessed early.
    There are various ways of manipulating the pages.
    <html>
    <head>
    <title> Window Title </title>
    <meta keywords="personal blog, full stack dev, devops">
    <script> .. </script>
    <style>...</style>
    </head>
    <body>
    <h1>Header 1</h1>
    </body>
    </html>
    ...
    ...

    <img src=""/>
    <a href="link">Some text to click </a>
    <audio>
    <video>
    <iframe>
    <table></table>
    Singleton tags like <img> do not have ending tag.
    Tags have properties/attributes
    We can define our own tags in frameworks like react.
    The attributes of user defined tags are called props.

    ..
    ..
    Javascript encountered in html is executed if in the form of statements or function calls. 
    If 
    functions are just defined without being called they just exist.
    There is no single entry point for js like main in "c c++ and java".
    The statements are executed from top to bottom in the order they are encountered.

    This is how a function is defined in js
    function add(a , b)
    {
    return a+b;
    }

    Full Stack Development- Class 1 - Introduction to Syllabus and MERN Stack

    HTML - Hyper Text Markup Language

    HTTP - Hyper Text Transfer Protocol

    CSS - Cascading Style Sheets

    JS - Javascript

    WWW was invented by tim berners lee in 1989 innovating on key technologies like HTML, HTTP and URI.

    URI stands for Uniform Resource Identifier.

    This is the link to the first webpage ever on the WWW. (Link)

    While the Internet grew rapidly after 1993 when CERN made the www software free to use, the launch of Windows 95 gave it an impetus that is felt even today.

    World wide web grew rapidly and search engines like yahoo became the primary engines of web search. Google with its page rank algorithm provided an alternative search that rated popularity of search engines based on their reputation calculated by incoming links from other popular sites.

    HTML pages were emitted by the servers and displayed in programs called the browser. The internet explorer, Netscape navigator, safari and Mozilla Firefox were some of the popular browsers.

    Browsers were improving rapidly. Windows NT and Linux with several of its flavors were popular choices of server OS.

    After around 30 years of the rise in popularity of the www, the landscape now is entirely different.

    CSS was primarily used for styling. JS was used to modify the attributes of the HTML elements.

    JavaScript was a language script embedded in the html and in the front end it made changes to pages by responding to events like for example, clicks or window resize, by doing some simple changes in properties of elements like for example, changing the color of visited pages from blue to red(to denote visited).

    Around 2008 java script has started to be used to run the backend server. NodeJS made its entry into the programming world where writing servers in JavaScript became possible. Popularity of JS grew by leaps and bounds because people saw value in it. They wanted to learn how to program the front end animations and styling changes.

    Technologies like AJAX(Asynchronous JavaScript and XML) made updating parts of the website easier without entire page refreshing. Progressive Web Apps were installable on desktops and didn't need separate development on various platforms. Single page applications a type of web application that loads a single HTML page and dynamically updates content via JavaScript as the user interacts with it, eliminating full page reloads.

    Front end frameworks like Vue JS, React JS and Angular JS gave birth to a new breed/designation of front end engineers. AngularJS has lost preeminence to react-js though.

    Flutter framework from google programmed in Dart gained popularity as it provided native UI experience on android and allowed people to design front end once and run on a variety of devices/browsers/mobiles from a single code base.

    MERN stack is an acronym for MongoDB, ExpressJS, ReactJS and NodeJS. MongoDB is a NoSQL database technology relying its own specialized binary representation of JSON called BSON (Binary JSON) as its native data format for storing data on disk, in memory, and over the network.

    MongoDB supports GraphQL as a query language. ReactJS is the front end framework that has features like hot reload, server side rendering, virtual dom, dom diffing etc.

    Node.js is an open-source, cross-platform JavaScript runtime environment letting developers run JavaScript in server and have a development environment in the frontend.