Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Javascript: Understanding the weird parts

Javascript: Understanding the weird parts

Javascript started out as a language used to make web pages dynamic, now Javascript runs almost everywhere. The sad part is that a lot of developers only learnt javascript to get things done and don't have an understanding of what happens under the hood. In this presentation, I talk about a few of the nuances of Javascript that give developers the popular "that's weird!" moments.

Presented at Cotta & Cush Tech Talks
Tech Talks is a weekly internal event at Cotta & Cush Limited featuring technical presentations, app reviews among other discussions

Adeyemi Olaoye

June 16, 2017
Tweet

More Decks by Adeyemi Olaoye

Other Decks in Programming

Transcript

  1. var a; console.log(a); if (a === undefined) { console.log('a is

    undefined!'); } else { console.log('a is defined!'); }
  2. var Tony = { firstname: 'Tony', lastname: 'Alicea', address: {

    street: '111 Main St.', city: 'New York', state: 'NY' }, fullname: function(){ return firstname + ‘ ’ + lastname; } }; var firstnameKey = ‘firstname’; console.log(Tony.firstnameKey); console.log(Tony.firstname); console.log(Tony.fullname);
  3. function a() { console.log(this); this.newvariable = 'hello'; } var b

    = function() { console.log(this); } a(); console.log(newvariable); // not good!
  4. var foo = function() { var bar = 'baz' return

    { bar: bar } } console.log(foo());