KEMBAR78
JavaScript – ECMAScript Basics By Satyen | PPTX
By: Satyen Pandya1JavaScript – ECMAScript Basicssatu21@gmail.com
Contents2   Syntax, Variables, Keywords, Reserved Words
   Primitive and Reference Values
   Primitive Types
   Conversions
   Reference Types
   Operators
   Statements
   Functionssatu21@gmail.com
Syntax3   ECMAScript basic concepts :
   Everything is case-sensitive
   Variables are loosely typed
   End-of-line semicolons are optional
   Comments are the same as in Java, C, Perl
   Braces indicate code blockssatu21@gmail.com
Variables4   Variables are defined by var operator
   Variables do not require initialization like JAVA
   Variables can hold different types of values at	different times   Variable name –
   First character must be letter, an underscore (_)\       or dollar sign ($)   Remaining characters may be underscores, dollarsings or any alphanumeric characters Variable should follow –
   Camel Notation (e.g. myTest, myVar)
   Pascal Notation (e.g. MyTest, MyVar)

JavaScript – ECMAScript Basics By Satyen

  • 1.
    By: Satyen Pandya1JavaScript– ECMAScript Basicssatu21@gmail.com
  • 2.
    Contents2 Syntax, Variables, Keywords, Reserved Words
  • 3.
    Primitive and Reference Values
  • 4.
    Primitive Types
  • 5.
    Conversions
  • 6.
    Reference Types
  • 7.
    Operators
  • 8.
    Statements
  • 9.
    Functionssatu21@gmail.com
  • 10.
    Syntax3 ECMAScript basic concepts :
  • 11.
    Everything is case-sensitive
  • 12.
    Variables are loosely typed
  • 13.
    End-of-line semicolons are optional
  • 14.
    Comments are the same as in Java, C, Perl
  • 15.
    Braces indicate code blockssatu21@gmail.com
  • 16.
    Variables4 Variables are defined by var operator
  • 17.
    Variables do not require initialization like JAVA
  • 18.
    Variables can hold different types of values at different times Variable name –
  • 19.
    First character must be letter, an underscore (_)\ or dollar sign ($) Remaining characters may be underscores, dollarsings or any alphanumeric characters Variable should follow –
  • 20.
    Camel Notation (e.g. myTest, myVar)
  • 21.
    Pascal Notation (e.g. MyTest, MyVar)
  • 22.
    Hungarian Type Notation (e.g. sMyTest, bMyVar)satu21@gmail.com
  • 23.
    Keywords5 Keyword used to indicate beginning and/or endingof statements Keywords are reserved, can not use as variable or function name Few Keywords :satu21@gmail.com
  • 24.
    Reserved Words6 Word that are reserved for future use as keyword
  • 25.
    Can not use as variable or function name
  • 26.
    Few Reserved words :satu21@gmail.com
  • 27.
    Primitive and ReferenceValues7Primitive values - simple piece of data, stored on stack, the value is stored directly in location that variable accesses Reference values - objects, stored in heap, the value is stored in variable location – pointer, where the object is storedsatu21@gmail.com
  • 28.
    Primitive Types8 ECMAScript has five primitive types :Undefined, Null, Boolean, Number, Stringtypeof Operator used to determine the type variable’svaluetypeof Operator takes one argument
  • 29.
    typeof returns oneof below value :
  • 30.
    “undefined”, “boolean”, “number”,“string”, “object”satu21@gmail.com
  • 31.
    Conversions9 Type conversion is a short, one-step process in ECMAScript
  • 32.
    Converting to astring : var.toString()
  • 33.
    Converting to a number :var a = parseInt(“123”);var b = parseFloat(“123.456”);Type Casting : Boolean(value); Number(value); String(value);satu21@gmail.com
  • 34.
    Reference Types10 They are referred as class, when you have a reference value, you are dealing with an object Objects are created by new operator and class namee.g. varobj = new Object(); Few classes :The Object classThe Boolean classThe Number classThe String classThe instanceof operatorsatu21@gmail.com
  • 35.
    Reference Types (Contd…)11Theobject class : base class for all ECMAScript classes
  • 36.
    All the properties and methods of Object class also present in other classes Properties :
  • 37.
  • 38.
  • 39.
    Methods :
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
    Reference Types (Contd…)12TheBoolean class : reference type for Boolean type
  • 46.
    pass only Boolean value
  • 47.
  • 48.
  • 49.
    The Number class : reference type for Number type
  • 50.
    pass only Boolean value
  • 51.
    toString() – returnsnumber primitive value
  • 52.
    valueOf() – returnsnumber primitive value
  • 53.
    toFixed() – returnsstring representation of number
  • 54.
    toExponential – returnse-notation string
  • 55.
    toPrecision – returnsfixed or e-notation of numbersatu21@gmail.com
  • 56.
    Reference Types (Contd…)13TheString class : reference type for String type
  • 57.
    pass only Boolean value
  • 58.
    toString() – returnsstring primitive value
  • 59.
    valueOf() – returnsstring primitive value
  • 60.
    length – gives number of characters
  • 61.
    charAt() – returnsstring containing character in position
  • 62.
  • 63.
    concat() – concatetwo or more strings
  • 64.
    indexOf() – returnsposition of given substring
  • 65.
    lastindexOf() – returnslast position of given substring
  • 66.
    The instanceof operator: identifies the type of objectsatu21@gmail.com
  • 67.
  • 68.
    delete – erases reference to an object property or method
  • 69.
    void – returns undefined for any value
  • 70.
    prefix increment/decrement (e.g. ++a, --a)
  • 71.
    postfix increment/decrement (e.g. a++, a--)
  • 72.
    unary plus – returns exact same value for integer, for string it converts them to numbers unary minus – returns negative value for integer, for string it negates the valuesatu21@gmail.com
  • 73.
  • 74.
    Bitwise NOT – tilde(~), it works in 3 stpesOperand is converted to 32-bit numberBinary form converted into its one’s complementOne’s complement is converted back to number Bitwise AND – ampersand(&)
  • 75.
    works directly on the binary form of numbers
  • 76.
    Bitwise OR – pipe(|)
  • 77.
    works directly on the binary form of numbers
  • 78.
    Bitwise XOR – caret(^)
  • 79.
    works directly on the binary form of numberssatu21@gmail.com
  • 80.
  • 81.
  • 82.
    Logical NOT – exclamation(!), always return Boolean
  • 83.
    Logical AND – double ampersand(&&)
  • 84.
    Logical OR – double pipe(||)satu21@gmail.com
  • 85.
    Multiplicative operators18Multiply :represented by asterisk(*)
  • 86.
    Divide : represented by slash(/)
  • 87.
    Modulus : represented by percent sign(%)Additive operatorsAdd : represented by plus(+)
  • 88.
    Subtract : represented by minus(-)
  • 89.
    Modulus : represented by percent sign(%)satu21@gmail.com
  • 90.
  • 91.
    greater-than : represented by >
  • 92.
    less-than-or-equal : represented by <=
  • 93.
    greater-than-or-equal : represented by >=Equality operatorsEqual : represented by double equal sign (==)
  • 94.
    Not Equal : represented by exclamation with equal sign (!=)
  • 95.
    Identically equal :three equal sign (===)
  • 96.
    Not identically equal: exclamation and two equal (!==)satu21@gmail.com
  • 97.
    Conditional operators20 Syntax :Variable = boolean_expression ? true_value : false_value; if expression is true then true_value will be assigned, else false_value will be assignedAssignment operators Simple assignment operator (=) assings the value on the right to the variable on the leftComma operators more than one operation in single linesatu21@gmail.com
  • 98.
    Thank you…By: SatyenPandya21satu21@gmail.com