###Objectives:
- Understand why JavaScript is so awesome
- Understand what an Object is
- Apply OOP principle to pseudocode an object
- Create an object in Sublime Text
- NOT to be confused with Java
- Created in 10 days in May 1995 by Brendan Eich
- Original name was Mocha, a named chosen by Marc Andreessen (Founder of Netscape)
- ECMAScript (European Computer Manufacturers Association) is the name of the official standard.
#Why is JavaScript important?
- All browsers have JavaScript interpreters built in!
- There are 3 ultra-fast JavaScript engines around (FireFox SpiderMonkey, Google V8, and Safari JavaScriptCore) fiercely competing to become faster and faster
- JavaScript is most popular programming language in the world!
##What IS JavaScript?
JavaScript is a scripting language because it uses the browser to do its work. It is flexible, and allows for creative programming designs. This mix of features makes it a multi-paradigm language, supporting object-oriented programming.
#Variables
Variables are containers for storing data values. Variables MUST be identified with unique names, called identifiers
- case-sensitive
- begin with a letter
- contain letters, digits, underscores, and dollar signs
var five = 5;
var rob = "Instructor";
###Functions are a way of actually doing things
function sayHello() {
console.log('hello');
}
// then we run our function after we create it
sayHello();
// we can also pass things into our function
function sayHello(name) {
console.log('hello ' + name);
}
sayHello('rob');
// or variables
var robName = 'rob';
sayHello(robName);
#Objects
- An Object-Oriented Programming (OOP) language is organized around objects.
- their 1) attributes and 2) behaviors
- attributes
- color
- price
- top speed
- behaviors
- drive
- stop
// Created a variable with the object, car!
var car = {};
car.color = "blue";
car.price = 50000;
car.drive = function(){
console.log("Drive");
}
car.stop = function(){
console.log("Stop");
}
car.turnOnLights = function(){
console.log("Lights are on");
}
#Arrays
An array is a data structure, AKA a way to organize data.
In JavaScript, it gives us the ability to store multiple values inside a single variable
// a cars variable contain cars
var cars = ['Infiniti', 'Volvo', 'BMW];
// print the variables out
document.write(cars[0]);
document.write(cars[1]);
document.write(cars[2]);