By: Daniel Henneberger.  Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function.

Slides:



Advertisements
Similar presentations
The JavaScript Programming Language
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Intro to Javascript CS Client Side Scripting CS380 2.
Intro to JavaScript. JavaScript History Client (generally browser-side) language invented at Netscape under the name LiveScript around 1995 Netscape wanted.
Programming Languages and Paradigms The C Programming Language.
Java Script Session1 INTRODUCTION.
1 CS101 Introduction to Computing Lecture 23 Flow Control & Loops (Web Development Lecture 8)
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
Kevin Reuter & Brian Guthrie.  Multi-paradigm  Prototype based objects  Dynamic, weak typing.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
JavaScript, Third Edition
Taking JavaScript Seriously IS NOT THE WORST IDEA.
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
JavaScript JavaScript is a scripting language that is most commonly used to add client- side programming to a web page. Some of the things it is used for.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Javascript & DOM. Javascript – main properties is a lightweight scripting language (language used to control the browser) that is run on the client-side.
An Overview of ActionScript The Powerful Scripting Language of Macromedia Flash.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
SE-2840 Dr. Mark L. Hornick 1 Modifying webpage behavior using client-side scripting Javascript.
Copyright By Free for non-commercial use. Editable provided that the copyright claim is included.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
JavaScript davide morelli history LiveScript (1995) in Netscape java script is a misleading name started as a scripting counterpart.
Programming Language C++ Xulong Peng CSC415 Programming Languages.
Introduction to JavaScript Gordon Tian
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
C Derived Languages C is the base upon which many build C++ conventions also influence others *SmallTalk is where most OOP comes Java and Javascript have.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
1 Overview JavaScript (Recommended Reading : Programming the World Wide Web, 4 th Edition, Robert W. Sebesta, Chapters 4, 5 – available at Steely Library)
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
School of Computing and Information Systems CS 371 Web Application Programming Client-side.
4.4 JavaScript (JS) Deitel Ch. 7, 8, 9, JavaScript & Java: Similarities JS (JavaScript) is case-sensitive Operators –arithmetic: unary +, unary.
Javascript. What is JavaScript? Scripting (interpreted) language designed for the web Beware: JavaScript is case sensitive.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
JavaScript, Fourth Edition
JavaScript History and Versions JavaScript was introduced as part of the Netscape 2.0 browser Microsoft soon released its own version called JScript ECMA.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
1 JavaScript in Context. Server-Side Programming.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
“The world’s most misunderstood language has become the world’s most popular programming language” Akshay Arora
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
JavaScript and Ajax (Control Structures) Week 4 Web site:
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Javascript Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
ActionScript Programming Help
JavaScript Introduction
Chapter 4 Client-Side Programming: the JavaScript Language
JavaScript for C++ and Java Programmers
JavaScript Syntax and Semantics
JavaScript an introduction.
Web Systems Development (CSC-215)
An overview of Java, Data types and variables
CS5220 Advanced Topics in Web Programming JavaScript Basics
Tutorial 4 JavaScript as OOP Li Xu
University of Kurdistan
CS5220 Advanced Topics in Web Programming Node.js Basics
CS3220 Web and Internet Programming JavaScript Basics
JavaScript CS 4640 Programming Languages for Web Applications
Javascript & DOM.
Introduction To JavaScript
CS3220 Web and Internet Programming JavaScript Basics
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

By: Daniel Henneberger

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

  Prototype-based scripting language  Interpreted?  Chrome V8 attempts to compile  Java’s Rhino attempts to compile to byte code  Mozilla attempts JIT  Garbage Collection – Up to implementer  Loosely-typed, First-class functions, dynamic  Java-like syntax  Two Subsets  Default Language (will be abandon later)  Strict Language  Free  The word JavaScript must be licensed by Oracle  Mozilla has ‘Inventor rights’ Brief

  Developed for client-side processing on web browsers  Now capable of other tasks  Web Servers (node.js)  Desktop Widgets  Inside Applications Applications

  Originally Called LiveScript  Created for Netscape Navigator by Brendan Eich  Renamed JavaScript  Most likely a marking ploy  Microsoft created Jscript  Formalized to ECMAScript  ISO/IEC  ECMAScript v2  ECMAScript v3 History of JavaScript

  – ECMAScript v4 (Abandoned)  Google’s V8 Engine  Node.js created  ECMAScript v5  Test262 created  ISO/IEC 16262:2011  ECMAScript v5.1 History of JavaScript

  2013 – Java 8’s JavaScript Engine (Nashorn)  201? ECMAScript v6  Only strict mode  Incompatible syntax  Classes  Getters/Setters  Tamper proof objects  Block Scoping Future of JavaScript

  Adobe, Mozilla, Microsoft  Later came IBM, Google, Apple, Opera, Dojo, and Company 100. ECMAScript Committee

 CodenameBrowserTest262 Fail Percent JscriptMicrosoft Internet Explo. 95.2% SpiderMonkeyFirefox1.5% FutharkOpera0.1% V8Chrome0.1% Implementations Test262 really important

  End of line semicolons optional  Automatically inserted by compiler  Excess whitespace and comments are discarded during lexical analysis  Strings can be defined by ' or "  Multiline Strings possible with \ Grammar

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

  var - has functional scoping  const  null  undefined  let has block scoping ( ECMAScript v6 )  let and const to replace var Usable Types

  Undefined - primitive value used when a variable has not been assigned a value  Null - no value  Boolean – true/false  Number - double-precision 64-bit  NaN, Positive Infinity, Negative Infinity  IEEE 754  String - UTF-16  Object  runtime system performs automatic type conversion as needed  1+true=2, null + false = 0, null != false, null == undefined  Type coercion – new Boolean(true); Internal Types

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

 Flow Control - Sequencing function test(){ for( var i = 0; i<10; i++){ //doSomething; } return i; } result is 10

  if ( Expression ) Statement else Statement  if ( Expression ) Statement  SwitchStatement: switch ( Expression ) CaseBlock  CaseBlock:  { CaseClause }  { CaseClause DefaultClause CaseClause }  CaseClause: case Expression : StatementList  Default Clause: default : StatementList  with( Expression ) Statement  LogicalORExpression ? AssignmentExpression : AssignmentExpression Flow Control – Selection

  Simple Assignment: =  Compound Assignment: op= *= /= %= += -= >= >>>= &= ^= |=  Comma Operator (, ) Flow Control – Expression Evaluation

  do Statement while ( Expression );  while ( Expression ) Statement  for ( ExpressionNoIn ; Expression ; Expression ) Statement  for ( var VarDeclaration ; Expression ; Expression ) Statement  for ( LeftHandSideExpression in Expression ) Statement  for ( var VariableDeclarationNoIn in Expression ) Statement  label, break, continue, (throw, return, ‘normal’) Flow Control – Iteration

  function Identifier ( ParameterList ) { FunctionBody }  function ( ParameterList ) { FunctionBody } function square(y){ this.rslt = y*y; } var x = new square(5); x.rslt; var square = new Function("a", "b", "return a*b") Flow Control – Procedural Abstraction var x = function(y) { return y * y; }; x(5); function square(y){ return y*y; } square(5); var Math = { square: function(y){ return y*y } Math.square(5);

  Object Properties Flow Control – Procedural Abstraction Object.defineProperty(o, "a", { value : 37, writable : true, enumerable : true, configurable : true, get : function(){ return bValue; }, set : function(newValue){ bValue = newValue; } });

  No optimization for Tail Call Recursion  No concurrency  setTimeout(func, delay, [params])  setInterval()  new Worker(“something.js”) Flow Control – Recursion/Concurrency

  try / catch  try / finally  try / catch / finally  try { Code } catch ( Identifier ) {Code} finally {Code}  throw  Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError and URIError Flow Control – Exception Handling

  Global - variables that are not declared but are referenced are automatically global  Eval  Strict Mode- cannot return variables  Creates a new binding  Function  function x(){t = 5}; x(); console.log(t) //5  function x(){var t = 5}; x(); console.log(t) //undef Execution Context

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

 function Person(){} function Ninja(){} Ninja.prototype = new Person(); (new Ninja()) instanceof Person var o = new Object(); o.[[Prototype]] = Foo.prototype; o.Foo(); Prototype Based Inheritance

  Number  parseInt()  parseFloat()  parseInt()  isNaN()  ifFinite()  eval()  Library  Math  JSON  Date  RegExp  Special Characters  decodeURI  encodeURI Built-in Functions

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

user defined types generics  NONE!

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

  new Array([item1, item2, …])  new Array(len)  Keys can be integers or strings  Can be treated as: Arrays, Queues, Stacks, Priority Queues, Set  No bounds  arr[arr.length] = I; Arrays

  push  pop  reverse  sort  sort(function)  shift  slice  splice  unshift  indexOf  every  lastIndexOf  some(function)  forEach(function)  map(function)  filter(function)  reduce(function)  reduceRight(function) Array Operations

 x = 42; // creates the property x on the global object var y = 43; // declares a new variable, y myobj = {}; myobj.h = 4; // creates property h on myobj myobj.k = 5; // creates property k on myobj delete x; // returns true (x is a property of the global object and can be deleted) delete y; // returns false (delete doesn't affect variable names) delete Math.PI; // returns false (delete doesn't affect certain predefined properties) delete myobj.h; // returns true (user-defined properties can be deleted) with(myobj) { delete k; // returns true (equivalent to delete myobj.k) } delete myobj; // returns true delete

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

  bind() is powerful  x.bind(this);  call() – allows calling inner functions with current bindings  toString() Built-in Function Functions

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

  Floating point arithmetic IEEE 754  !== 0.3  A bad choice  All implementations see to behave differently  Code not portable  Accidental scoping  Global variables  var a = 0 || "4";  a = "4“  Scope hoisting  eval() Quirks

 Introduction  Data Types  Flow Control  Inheritance/Built-in Functions  User defined types, Generics  Arrays  Function methods  Quirks  Comparison

 JavaScriptJavaCGo Type Loosely Typed Strongly Typed Inheritance PrototypalClassical Automatic Multiple Inheritance No Yes Generics NoYesNo Pointers NoYesNoYes Closures YesNo Yes Exceptions Yes NoBuilt-in Threads NoYes Garbage Collection Yes NoYes Semi-Colon Optional YesNo Yes Like JavaScript 100%30% 40%

“Java and Javascript are similar like Car and Carpet are similar.” Greg Hewgill

 /publications/files/ECMA-ST/Ecma-262.pdf References