About you

Brief History

  • 1995: Created by Brendan Eich, Netscape
    • Originally named LiveScript
    • Renamed for marketing purposes
  • 1997: Submitted to ECMA
  • 2005: AJAX
The most commonly used language
(measured by StackOverflow and GitHub usage)
Languages built on top of JavaScipt

ECMAScript

https://en.wikipedia.org/wiki/ECMAScript#Versions

The programming language

Characteristics

  • Lightweight
  • Dynamic (interpreted run-time)
  • Weakly typed
  • Multi paradigm (functional, object oriented, etc)
  • != Java

Object

Basically, a collection of name-value pairs

                            let object = {
                                foo: 'bar',
                                age: 42,
                                baz: {
                                    myProp: 12
                                }
                            }
                            

                            let object = new Object();
                                object.foo = 'bar';
                                object['age'] = 42;
                                let bazPropertyName = 'baz';
                                object[bazPropertyName] = { myProp: 12 };
                            }
                            

Function (I)


                            function add(x, y) {
                              let total = x + y;
                              return total;
                            }
                        

Function (II)

Functions are first-class objects
Can have properties and methods
As oposed to other objects, functions can be called

Function (III)

Callback example

                            function doSomething(a, b, func) {
                                return func(a,b);
                            }

                            doSomething(10, 2, Math.pow) //100
                            doSomething(10, 2, add)      //12
                        

Other types

  • null
  • undefined

Variables

  • `let` - block level variable
  • `const` - block level constant

Control structures

  • `if` - `else
  • `while`
  • `do` - `while`
  • `for`
  • `switch`

FizzBuzz

FizzBuzz prints the numbers from 1 to 100.
For multiples of three, print “Fizz” instead.
For multiples of five print “Buzz”.
For multiples of both three and five print “FizzBuzz"
Jasmine test
                            
                            describe("answer", function() {
                                it("to life the universe and everything", function() {
                                    expect(answer()).toEqual(42);
                                });
                            });
                            
                        
                            
                            function answer() {
                                return 42;
                            }
                            
                        
AJAX call, using axios
                            
                                axios.get("/some/url").then(responseHandler);

                                function responseHandler(response) {
                                    //prosess response data
                                    outerVariable = response.data;
                                }
                            
                        

Good parts