JavaScript Justin Skinner Programming Languages
JavaScript JavaScript is not Java nor a subset But JavaScript does share the C-family syntax with Java One of the most popular programming language, most web browser now a days has a JavaScript interpreter JavaScript is found in the html code
JavaScript: “Hello World” Hello World using JavaScript document.write(“Hello World”)
Brief History JavaScript was first known as LiveScript Developed by Brendan Eich in 1995 Standardization
Data Types Three primitive types boolean number –NaN (Not a Number) –Infinity string
Objects Objects are implemented as hash-tables Objects are just containers of name/value pairs Similarity and differences with Java’s objects Object creations
Example Creating Objects Nested Objects Object literal notation var student = new Object(); student.name = “Mary Jane”; student.finalgrade = “A”; student.finalgrade.testgrade = “B”; student.finalgrade.homeworkgrade = “A”; var students = {name: “Mary Jane", finalgrade: “A”};
Functions Like C functions, except they have a keyword function instead of a type Calling the functions doesn’t require a fixed number of parameters Supports inner function Can have anonymous functions Functions are first class objects in JavaScript
The END!! Any Questions?