• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Learnjs
 

Learnjs

on

  • 319 views

 

Statistics

Views

Total Views
319
Views on SlideShare
319
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Learnjs Learnjs Presentation Transcript

    • Learn you some JavaScript for the great good
    • Why learn you JavaScript? It's such awesome!
    • Why such awesome? ● Closures ● Functions is first class such power ● So fast
    • Goal of lesson ● Understand: function Person (name) { this.name = name; } Person.prototype.getName = function () { return this.name; } ● Wow very function
    • So variables in JavaScript ● Variables are declared: var doge = 'doge'; ● Data types: 1. Number 2. Object 3. Array 4. Strings 5. Booleans
    • Much examples var dog = 'doge'; var dog = {name: 'doge'}; var dog = ['dog']; var isDoge = true; var numDoge = 1; //only one doge!
    • Wow Objects var person = {name: 'Bill', age: 33}; console.log(person.name) //'Bill' console.log(person.age) //33
    • Much Functions function doFizzBuzz (range) { var i = 0, toReturn = ''; for (i = 0; i < range; i++) { if (i % 3 === 0) { toReturn += 'Fizz'; } if (i % 5 === 0) { toReturn += 'Buzz'; } toReturn += 'n'; } return toReturn; }
    • Functions === Objects
    • Much idiomatic function doFizzBuzz (range) { var i = 0; for (i = 0; i < range; i++) { if (i % 3 === 0) { this.result += 'Fizz'; } if (i % 5 === 0) { this.result += 'Buzz'; } this.result += 'n'; } }
    • Much high order function //interval stores the id of this interval var interval = window.setInterval(function () { if (this.isVisible === true) { document.getElementById('change').style.visibility = 'hidden'; this.isVisible = false; } else { document.getElementById('change').style.visibility = 'visible'; this.isVisible = true; } }, 500);