Fan The Flame Inside Of Me

Fan The Flame Inside Of Me

Quoting Charlotte Gainsbourg as usual.

Because my heart is on fire, my heart is on fire. And like the song - "Set Yourself On Fire" - I just want to fuel my passion and set it alight more and more. The more I burn the fire, the brighter it burns. And I love what I do, I love it SO, SO MUCH, I just love it. And it burns brighter every day than it ever did before.


AND I LOVE IT.

Methods

"When the data stored on an object is a function we call that a method." - Codecademy

Another great quote on this:

"In JavaScript methods are object properties containing a function definition".

To call the method of an object, the following syntax is used:

objectName.methodName();

The way a method looks inside of an object is this (just to quote the Codecademy example directly):

Or rather, there are two way - the old way:

const alienShip = {
  invade: function () {
    console.log("Hello! We have come to dominate your planet. Instead of Earth, it shall be called New Xaculon.')
  }
};

And the new ES6 way - which I prefer.

const alienShip = {
  invade () {
    console.log("Hello! We have come to dominate your planet. Instead of Earth, it shall be called New Xaculon.')
  }
};

So the colon is omitted and so is the function keyword.

Again, just as it said above, to call the method above, all you have to do is write this:

alienShip.invade();

Note To Self

So to call a method, even though it says it above twice, let me please just say it one more time: \

You have to put:

nameOfObject.nameOfMethod

so for

const susanna = {
  job: 'Trainee Software Engineer',
  age: 28,
  loves: 'music',
  classicSusanna () {
    console.log('I live and love to be a Software Engineer');
  }
}

to call the classicSusanna method, you need to write:

susanna.classicSusanna();

//Output: I live and love to be a Software Engineer

The this Keyword

I didn't get on to this today - as in, I did do it at work, but not the blog post.

Arrow Functions And this 

You should avoid using arrow function expressions in Objects and just use function declarations. 

According to the MDN: "Arrow function expressions should only be used for non-method functions because they do not have their own this". 

Eh? 

Chung helped me with this omg and he clarified that the first sentence in this section is the main thing I need to know.

Comments

Popular posts from this blog

Hello World

Yosemite

Two Lines of Thought, Makes Me Wonder What I'm Missing