Means that the identifier can’t be reassigned

const name = 'Shane'

Means that the identifier may be reassigned. Such as a counter in a loop, or a value swap in an algorithm. It also signals that the variable will be used only in the block it’s defined in, which is not always the entire containing function.

let age = 23

Key difference between var and let – let is only visible in the for() loop and var is visible to the whole function.

function allyIlliterate() {
    //tuce is *not* visible out here

    for( let tuce = 0; tuce < 5; tuce++ ) {
        //tuce is only visible in here (and in the for() parentheses)
        //and there is a separate tuce variable for each iteration of the loop

    //tuce is *not* visible out here

function byE40() {
    //nish *is* visible out here

    for( var nish = 0; nish < 5; nish++ ) {
        //nish is visible to the whole function

    //nish *is* visible out here

N.B. you have to initialize your const and let identifiers before using them as typeof won’t work.

Arrow functions
Shorter syntax for writing function expressions

// ES5
var nameIs = function(name) {
   return name

// one parameter
var nameIs = name => {return name}

// More than one parameter
var nameIs = (x, y) => {return name}

// No parameter
var nameIs = () => {return name}

With array methods

var names = [
    name: 'shane',
    age: 13
    name: 'paul',
    age: 21

var sorted =
  names => names.age


Template literals

var a = 5;
var b = 10;
console.log(`Fifteen is ${a + b}`);
// "Fifteen is 15"

ES6 Arrow functions – Sitepoint
ES6 – Zell Liew
ES6 Cheatsheet – DrkSephy
JavaScript ES6+: var, let, or const – Eric Elliot
Template Literals – Exploring JS

Posted on

Other library topics


Worthy of Note

Worthy of Note is a site aimed at Web Designers & Developers. It offers a wide range of resources to help assist anyone in the web industry.