Introduction to Javascript

(My Understanding from different reads)

Types

It all starts with Data Types and following are them to start with.
Declarations:
    var a;          // Declaration
    a = 0;          // a has a value.
    // TYPES
    a = 2;          // Numbers
    a = 0.01;       // Both Integers and Real fall under Numbers
    a = "js";       // String Declarations using Single Quote
    a = 'js';       // String Declarations using Double Quote.
    a = true;       // Boolean
    a = false;      // alternate value of Boolean
    a = null;       // null is a special value which means a null -- will talk more
    a = undefined;  // undefined is similar to null -- will talk more.

Objects & Arrays

Hmm.... Objects and Arrays integral part of each and every programming language.
Object:

An object is a collection of name/value pairs, or a string to value map

Array:

Array is a numerically indexed lists of values


    //OBJECTS

    var book = {
        title : "JS",
        taf : true
    };

    //Access

    book.title              // Access with  .  or [ ]
    book["taf"]
    book.name = "JSBOOK";   // Add properties
    book.contents = {} ;    // empty object

    //ARRAYS can be accessed only with indexes in square brackets.

    var primes = [2,3,4,5]
    primes[0]
    primes.length
    primes[primes.length - 1]

Arrays and Objects can hold other objects and arrays
    var coordinates = [
        {x:0,y:0},
        {x:1,y:1}
    ];

    var data = {
        d1: [[1,2],[3,4]],
        d2: [[2,3],[4,5]]
    };


Expressions & Operators

Initializer Expression
Syntax for listing array elements within Square braces or mapping Object Property names to property values inside curly braces.
Expression:
computes a value, but doesnot do anything, doesnot change the state of program in anyway.

Statements

Statement:
Do not have a value but they alter the state of program.

Functions

A function is a named and parametrized block of JavaScript code that you define once, and can then invoke over and over again. When we combine functions with objects, we get methods: Client-side JavaScript does not exhibit the nonlinear cross-reference problem nearly to the extent that the core language does, and it is possible to learn how to use JavaScript in web browsers in a fairly linear sequence. There are two exceptions to the general rule that JavaScript interprets line breaks as semicolons when it cannot parse the second line as a continuation of the statement on the first line. The first exception involves the return, break, and continue statements The second exception involves the ++ and −− operators

Similar Stories


learnJavascriptBasicsFirst

Lexical Structure of Javascript

Lexical Structure of Javascript Optional Semicolons There are two exceptions to the general rule that JavaScript interprets line breaks as semicolons when it... Read More

learnJavascriptBasicsFirst

Intro to Javascript

Introduction to Javascript (My Understanding from different reads) Types It all starts with Data Types and following are them to start with. Declarations:... Read More

BabyStepsinTechnology

My Baby steps with Technology

My First Experiment with Computers. preparing a Lab Manual I used IIT-BHU Library Computers which have Ubuntu OS, Which has proxy with username... Read More