ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalEC-332Javascript Introductio…
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    EC-332

    Enterprise Application Development

    Progress0 / 37 done
    Topics37
    1Microsoft technology history2Introduction to .NET and its architecture3Concept of MSIL, CLR, CLS, CTS
    4Managed and Unmanaged Code5.Net Assembly6Introduction to C# fundamentals7Boxing and Unboxing8Implementing multi-tier architecture
    9SQL Injection, parameterized queries10Usage of data set, Data adapter and command builder in disconnected model
    11Multicast delegates12Introduction to windows forms13HTML
    14javascript and its data types, variables, functions15Debugging javascript using Firebug
    16Browser's Object (BOM), Document Object Model
    17Jquery effects
    18LINQ to Objects, LINQ to SQL19Query syntax, Operations (projection, filtering and join) using Linq Queries
    20The entity data model, CSDL21Eager vs lazy loading, POCO classes, DBContext API22Querying entity data models23Introduction to ASP.NET MVC24MVC application structure, Controllers overview25Action Methods, Parameterized action methods26Introduction to razor syntax27Code expressions, Code Blocks, Implicit Vs Explicit Code Expression28Data annotations, Client and Server Side Validation29Validation and model binding, Validation and model state30MVC Membership, Authorization and security
    31SOAP, WSDL32Service contract, Data contract, XML, WCF bindings33ABC of WCF, Restful services34Consuming rest services (CRUD operations) using Jquery AJAX and JSON35Introduction to web API36Example of web API using CRUD Example37MVC routing
    6 min read
    Topic 14 of 37
    Topic Study Note Illustration
    14

    Introduction to javascript: javascript and its data types, variables, functions

    JavaScript is a high-level, dynamic, and interpreted programming language that is commonly used to create interactive effects within web browsers. It is a client-side scripting language ,...

    Introduction to JavaScript

    JavaScript is a high-level, dynamic, and interpreted programming language that is commonly used to create interactive effects within web browsers. It is a client-side scripting language, meaning it runs in the web browser, allowing developers to create interactive web pages, handle user events, and manipulate the DOM (Document Object Model) in real-time. JavaScript is an essential technology for web development, alongside HTML and CSS, forming the backbone of web application interactivity.

    JavaScript Features:

    • Dynamic and Lightweight: JavaScript allows developers to write code that is lightweight and can be modified dynamically, making it fast for web applications.
    • Versatile: JavaScript can be used for both client-side and server-side development (Node.js for server-side).
    • Event-Driven: JavaScript reacts to events like clicks, mouse movements, and form submissions.
    • Cross-Platform: JavaScript works on all modern browsers and is also used in cross-platform mobile development (e.g., React Native).

    JavaScript Syntax:

    1. Case Sensitivity: JavaScript is case-sensitive. For example, variable and Variable are treated as different identifiers.
    2. Statements: JavaScript statements end with a semicolon (;), though semicolons are optional in most cases.

    JavaScript Data Types

    JavaScript has several primitive data types and objects that help you store and manipulate data. The primary data types include:

    1. Primitive Data Types:

    • Number: Represents both integer and floating-point numbers.
      let age = 25;   // integer
      let price = 19.99;  // floating point
      
    • String: Represents a sequence of characters.
      let name = "Alice";  // string
      
    • Boolean: Represents a value that is either true or false.
      let isActive = true;   // boolean
      
    • Undefined: A variable that has been declared but not assigned a value is automatically assigned undefined.
      let car;  // undefined
      
    • Null: Represents an intentional absence of any value. It is explicitly assigned.
      let user = null;   // null
      
    • Symbol: A unique and immutable primitive value often used as object property keys (introduced in ES6).
      let sym = Symbol('unique');
      
    • BigInt: Represents integers larger than 2^53 - 1, introduced in ES11 (ECMAScript 2020).
      let bigNum = 123456789123456789123456789n;  // BigInt
      

    2. Complex Data Types (Objects):

    • Object: Represents a collection of key-value pairs, useful for storing more complex data.
      let person = {
          name: "John",
          age: 30,
          city: "New York"
      };
      
    • Array: Represents a list-like collection of values, indexed by numbers.
      let colors = ["red", "green", "blue"];
      

    JavaScript Variables

    In JavaScript, variables are used to store values. There are three ways to declare variables:

    1. var: This is the traditional way to declare variables, but it has some limitations (such as function scoping). It’s considered less commonly used in modern JavaScript.
      var name = "Alice";
      
    2. let: Declares a block-scoped variable (introduced in ES6) that can be reassigned. It’s preferred over var in most cases.
      let age = 25;
      age = 26;  // reassignment is allowed
      
    3. const: Declares a block-scoped variable that cannot be reassigned (it’s constant). It must be assigned a value when declared.
      const pi = 3.14159;  // cannot be reassigned
      

    JavaScript Functions

    A function in JavaScript is a block of code designed to perform a specific task. Functions can accept inputs (parameters) and return outputs (return values). Functions are one of the building blocks of JavaScript, allowing for code reusability and modularity.

    1. Defining a Function:

    You can define a function using the function keyword.

    function greet(name) {
        return "Hello, " + name + "!";
    }
    

    2. Calling a Function:

    Once a function is defined, you can call (or invoke) it by using the function name and providing any required arguments.

    let message = greet("Alice");  // calling the function
    console.log(message);  // Output: Hello, Alice!
    

    3. Function Parameters and Return Values:

    • Parameters: Functions can accept parameters, which are values you pass into the function.
    • Return: Functions can return a value, which can be used or stored in a variable.

    Example:

    function add(a, b) {
        return a + b;
    }
    
    let result = add(5, 3);  // result will be 8
    console.log(result);  // Output: 8
    

    4. Anonymous Functions:

    An anonymous function is a function without a name. It can be assigned to variables or passed as arguments to other functions.

    Example of an anonymous function assigned to a variable:

    const multiply = function(a, b) {
        return a * b;
    };
    console.log(multiply(4, 3));  // Output: 12
    

    5. Arrow Functions (ES6):

    Arrow functions provide a more concise way to write functions. They also have a different behavior for this.

    const subtract = (a, b) => a - b;
    console.log(subtract(10, 4));  // Output: 6
    

    JavaScript Control Structures

    JavaScript also provides several control structures to handle decision-making and looping:

    • If-Else Statement: Used to execute code based on conditions.

      let number = 10;
      if (number > 5) {
          console.log("Greater than 5");
      } else {
          console.log("Less than or equal to 5");
      }
      
    • Switch Statement: A more readable alternative to multiple if-else conditions.

      let day = "Monday";
      switch(day) {
          case "Monday":
              console.log("Start of the week");
              break;
          case "Friday":
              console.log("End of the week");
              break;
          default:
              console.log("Midweek");
      }
      
    • Loops: JavaScript offers several looping mechanisms such as for, while, and forEach.

      For loop:

      for (let i = 0; i < 5; i++) {
          console.log(i);  // Output: 0, 1, 2, 3, 4
      }
      

      While loop:

      let j = 0;
      while (j < 5) {
          console.log(j);  // Output: 0, 1, 2, 3, 4
          j++;
      }
      

    Conclusion

    JavaScript is a powerful and versatile language, enabling developers to create dynamic, interactive web pages. Understanding its fundamental concepts such as data types, variables, and functions is key to mastering the language. By leveraging these tools, you can develop a wide variety of web applications, from simple dynamic effects to full-fledged web applications.

    ← Previous topic 13
    HTML
    Next topic 15 →
    Debugging javascript using Firebug

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    6mremaining
    1.1kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Enterprise Application Development