Skip to content

Instantly share code, notes, and snippets.

@lukasz-zak
Last active December 27, 2015 15:09
Show Gist options
  • Save lukasz-zak/7346121 to your computer and use it in GitHub Desktop.
Save lukasz-zak/7346121 to your computer and use it in GitHub Desktop.
ECMAScript 6 - const examples
(function () {
var foo = 'foo';
const bar = 'bar';
buzz = 'buzz';
console.group('Before changes');
console.info("inital value of foo:", foo);
console.log("inital value of bar:", bar);
console.log("inital value of buzz:", buzz);
console.groupEnd('Before changes');
foo += buzz;
bar += buzz;
buzz = null;
console.group('After changes');
console.log("here is foo:", foo);
console.log("here is bar:", bar);
console.log("here is buzz:", buzz);
console.groupEnd('After changes');
bar = 'foo';
console.log('Re-assign try: ', bar);
// const bar = 'foo';
// console.log('Re-initialize try: ', bar);
// var bar = 'foo';
// console.log('Re-declare try: ', bar);
const sidesEnum = {
l : 'left',
r : 'right'
};
console.log(sidesEnum.l);
console.log(sidesEnum.r);
const fn = function () {
console.log('This is const function');
console.log(bar);
var bar = 'foo';
console.log("test bar ", bar);
};
fn();
const numberOfMonths = 12;
const initDate = Date.now();
console.log(initDate);
setTimeout(function(){console.log(initDate);}, 2000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment