WDI Darth Vader

Object-oriented Javascript and jQuery

Week 2, Day 1

Block 1: How the Internet Works

  • Understand the difference between a client and a server
  • Be able to build URLs
  • Have a fundamental knowledge of security

OSI Model

osi

Network Ports + Glossary

See this markdown page.

URI/URL Structure

protocol://subdomain.domain.com:port/resource

Block 2: Objects in Javascript

  • Ability = method (a function owned by an object) = verb
  • Attribute = property = noun
  • Objects contain a key with an associated value.
  • Attributes must be numbers, strings, arrays, or other objects
  • Abilties must be functions
  • var obj = {}; or var obj = new Object();
  • Does an Object contain an attribute or ability? Check using myObject.hasOwnProperty("nameOfProperty");
  • More here:

Example

// best practice
var james = {

    name: "James",
    age: 31,
    saySomething: function() {
        console.log("yolo is a no go");
    },
    isCool: false,
    friends: ["Tom", "Marion", "Angie", "all y'al"],
    goOutside: function() {
        console.log("/me goes outside!!!!!");
    }
};

// old school
var james = new Object();
james.name = "James";
james.saySomething = function() {
    console.log("yolo is a no go");
};
james.isCool = false;

// array vs object
var arr = [];
var obj = {};

Block 3: Object Lab