Learn JavaScript 03

In this part let’s talk about some important things like syntax, variables, ….etc.

  • JavaScript uses the var keyword to declare variables.var x;
    x = 10;

     

  • JavaScript uses an assignment operator ( = ) to assign values to variables.var x = 4;
    var y = 10;

     

  • JavaScript uses arithmetic operators ( + – *  / ) to compute values.(2 + 3) * 6;

     

  • JavaScript allows you to work with three primitive data types.Numbers: 12, 12.50
    Strings: “Hello Sam”
    Boolean: true or false.
  • JavaScript comments. Code after double slashes // or between /* and */ is treated as a comment.// This is a single line comment.

    /*
    This is a multi line
    comment in JavaScript
    */

  • JavaScript variables must be identified with unique names.
    These unique names are called identifiers.
    JavaScript identifiers. In JavaScript, the first character must be a letter, an underscore (_), or a dollar sign ($). Subsequent characters may be letters, digits, underscores, or dollar signs.

    Numbers are not allowed as the first character.
    JavaScript identifiers are case sensitive.

  • JavaScript Arithmetic Operators
    Operator Description
    + Addition
    Subtraction
    * Multiplication
    / Division
    % Modulus
    ++ Increment
    Decrement
  • JavaScript Assignment operators.
    Operator Example Same As
    = x = y x = y
    += x += y x = x + y
    -= x -= y x = x – y
    *= x *= y x = x * y
    /= x /= y x = x / y
    %= x %= y x = x % y
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s