ES6: the basics

let declarations

Allow you to define a variable that only exist inside a block delineated by { and }

Example:

var a = 0;
{
  let a = 1;
  console.log(a); // prints 1
}
console.log(a); // prints 0

let declarations are not initialized until they are used, that is why it is a good idea to put them at the top of the block, to avoid weird behavior. If you are not ready to attach a value, you can just say: let a;

const declarations

By using const, once the assignment has been made, it can’t be undone.

Example:

{
    const a = 7;
    console.log(a);   // 7
    a = 5;              // TypeError!
}

If you assign Objects or Arrays to constants, you can still modify the values, you just can’t modify the assignment type:

{
    const a = [1,2,3];
    a.push(4);
    console.log(a);       // [1,2,3,4]
    a = 42;                 // TypeError!
}

Angularjs: template to setup just the UI part

Setting this up with Vagrant (therefore the extra steps / packages downloaded):

$ mkdir src; vagrant init ubuntu/trusty64

$ vi Vagrantfile // modify the following lines:

from:  # config.vm.network “forwarded_port”, guest: 80, host: 8080

to:

  config.vm.network :”forwarded_port”, guest: 3000, host: 3000

from: # config.vm.synced_folder “../data”, “/vagrant_data”

to:

 config.vm.synced_folder “./src”, “/home/vagrant/[your project name]”

$ vagrant ssh

Once you are inside the vagrant instance:

$ sudo apt-get install git

git clone –depth=1 https://github.com/angular/angular-seed.git [your_project_name]

Installing NPM:

sudo apt-get update

$ sudo apt-get install nodejs

$ sudo apt-get install npm

$ sudo ln -s /usr/bin/nodejs /usr/bin/node

Initialize and start the project:

npm install

$ python -m SimpleHTTPServer 3000 // to see your files in a simple server

The rest of the details (like testing, and updating angular and the other packages) are in:

https://github.com/angular/angular-seed

Running your code in production:

You just need all the static files inside your app/ directory in a server, that’s it!