Now run `npm run build` and take a look at compiled.js:
```JavaScript
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i <props.length;i++){vardescriptor =props[i];descriptor.enumerable =descriptor.enumerable||false;descriptor.configurable =true;if("value"indescriptor)descriptor.writable =true;Object.defineProperty(target,descriptor.key,descriptor);}}returnfunction(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);returnConstructor;};}();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Car = function () {
function Car() {
_classCallCheck(this, Car);
}
_createClass(Car, [{
key: "run",
value: function run() {}
}]);
return Car;
}();
```
That's a spicy meatball!
If you want, you can adjust `package.json` to re-compile every time you make a change:
Normally, variable declarations, are "hoisted" up to the top of whatever function they are declared in (or global if no function exists). This can lead to some weird moments:
@ -93,7 +163,7 @@ IIFE - Immediately Invoked Function Expression - often used to create a block of
```JavaScript
var a = 2;
(function IIFE(){
(function(){
var a = 4;
console.log ('Inside the IFFE, the value of a is', a ); //"Inside the IFFE, the value of a is 4"
Here is an example of the arrow function binding this
with callbacks, `this` can get redefined:
```JavaScript
// Create constructor function, inputs name, has default friend values
function Person ( name , friends = ["Charlie", "Dennis", "Ron", "Sweet Dee", "Frank"]){
function Person(name){
this.name = name;
this.friends = friends;
//Add four methods:
// The first, `secret Admirer`, `this.name` is undefined in the forEach function
this.secretAdmirer = function (){
this.friends.forEach(function ( f ){
console.log( this.name + " sends flowers to " + f );
});
}
//The second one is the way we got around the issue of `this` - which was to set the desired `this` to a variable called `that` or `self` or something similar:
this.giveOldSchoolLove = function (){
var self = this;
this.friends.forEach(function ( f ){
console.log( self.name + " likes " + f );
});
}
// we could also use .bind()
this.giveBindingAffection = function (){
this.friends.forEach(function ( f ){
console.log( this.name + " makes friendship bracelets for " + f )
}.bind(this));
this.logName = function(){
setTimeout(function(){
console.log(this.name);
},500)
}
}
var me = new Person('Matt');
me.logName();
```
//Finally, by using the arrow function, `this` is already bound: