Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Programming Basics with JavaScript

Tom Wilson
November 11, 2012
170

Programming Basics with JavaScript

Tom Wilson

November 11, 2012
Tweet

Transcript

  1. Whoami • Tom Wilson • Head Instructor of ChsCodeCamp •

    President of Jack Russell Software • Twitter: @twilson63 • Github: twilson63
  2. What is programming? Programming is a creative process done by

    programmers to instruct a computer on how to do a task.
  3. How do computers work? • Processing (CPU) • Memory (RAM,

    HD) • Input (Keyboard, Mouse, Camera, Mic, Net) • Output (Monitor, Printer, Internet)
  4. Art of talking to Machines • Machines speak 0 and

    1 • Humans speak complex languages • Software Languages bridge the gap
  5. Basic Types • Numeric Types Numeric types are simply expressed

    by entering the number: 1 or 3.5 Exercise 2
  6. Arithmetic Operators + Addition add the left and right -

    Substracts right hand from left * Multiplies values on either side / Divides left hand operand from the right % Divides left by right and returns remainder Exercise 2a
  7. Variables A variable is something that can be changed. Assigning

    values to symbols that make easier for humans to reference and maintain. var greeting = "Hello"; var ONE = 1; var TWO = 2;
  8. Variables (CONT) var ONE = 1; var TWO = 2;

    say(ONE + TWO); var greeting = "HELLO"; say(greeting); greeting = "HOLA"; say(greeting);
  9. Assignment Assignment statements assigns a value to a declared variable.

    A variable is a set of symbols and characters combined to form a unique representation in the program to point or reference data. You create these variables by using a reserved word called ‘var’. This world instructs the program to create a reference from the word on the left side of the statement of the data or reference on the right. Using the assignment operator ‘=’ as the character that bridges the statement.
  10. Assignment Operators = Assign right side to left variable y

    += x y = y + x y -= x y = y - x y *= x y = y * x y /= x y = y / x y %= x y = y % x
  11. Conditional Statements // if statement if (true) { // do

    something } // if else statement if (true) { // do something } else { // do something }
  12. Logical Operators // less than if (1 < 2) {

    // do something } // greater than if (2 > 1) { // do something }
  13. Basic Comparison Operators === Equals !== Not Equals < Less

    Than > Greater Than <= Less Than or Equals >= Greater Than or Equals Exercise 5
  14. Functions Block or set of statements grouped together and can

    be invoked by other statements. var greeting = function() { return "Hello"; } // call functions by adding parens at the end say(greeting());
  15. Complex Types Objects JavaScript Objects represent self contained entities consisting

    of variables (called properties in object terminology) and functions (called methods) that can be used to perform tasks and store complex data. var emptyObject = {};
  16. Complex Types Objects (CONT) function Dog(breed) { this.breed = breed;

    this.bark = function() { say('woof') }; } var jack = new Dog('Jack Russell'); jack.bark();
  17. ATM Banking Example We will create an ATM Application: 1.

    Deposit Funds 2. Withdraw Funds 3. Check Balance
  18. Building Blocks By having the power to create functions, you

    can create building blocks that create a level of abstraction that makes coding easier and managable.