Have To Be Around You

 Have To Be Around You

"Have to be around you, to know how I feel

Hate to be around you, to know how to feel". - Brooke Bentham

I discovered the above song a fair few days ago when I was working from home. 

I have been completely obsessed ever since. I have been listening non-stop over the weekend. It reminds me Laurel a bit and her Sonic Youth inspired phase


Album artwork for Have To Be Around You

I absolutely love this kind of music. I just find it so healing 💖🤗

I love the freedom and the wildness that is expressed through this music. 💓💞💕💞💕

"Expressive Functions" 

I was very very tired at the end of day on Friday. 

And I said that I would work on "expressive functions" on Monday. Lol!!!! Looks like they were actually called Function Expressions. Whoops lol haha. 

Function Expressions

Okay so the very first thing that I have gotten out of this is that function expressions are different from function declarations. 

Okay I've just realised that the FIRST STEP OF WRITING A FUNCTION EXPRESSION is to "declare a variable to make the variable's name the be the name, or the identifier, of [my] function". 

ALSO 

"To invoke a function expression, write the name of the variable in which the function is stored followed by parentheses enclosing any arguments being passed into the function". 

i.e. then it would look something LIKE THIS: 

variableName(argument1, argument2)

Then Codecademy throws in this really unhelpful little curveball: 

"Unlike function declarations, function expressions are not hoisted so they cannot be called before they are defined".

-> OMG, I think that I get this, actually!
  • Hoisting is this thing
  • It is to do with the order in which code is read
  • With HOISTING it is something like this
    • You can call the function
    • The function gets declared later
    • Because of the way the computer reads the code (compiles/interprets, I can't remember, humour me, and even better yet, help me out here please 😂) the function declaration gets read even though the function declaration comes after the function is called
  • It DOESN'T WORK LIKE THIS with function expressions
  • Therefore, YOU HAVE TO DEFINE FUNCTION EXPRESSIONS BEFORE YOU CALL THEM. 
It just so happens that Adam (Engineering Manager from work ✨✨) sent me a really amazing example of hoisting and although it clicked immediately I'd like to put it here for revision purposes and for anyone else to read in case they find it useful/helpful. 

const test1 = () => {
  console.log(funcA() + 1)
}

const test2 = () => {
  console.log(funcB() + 1)
}

test1() // This works and you get 2 because funcA was hoisted :D 
test2() // This doesn't work because funcB is not defined D:

function funcA() {
  return 1
}

const funcB = () => {
  return 1
}

I truly truly love this example! Especially the faces - :D and D: - ahaha, I love them!

Still On Expressive Functions

Okay so still on this - 

here is the syntax once again for creating an anonymous function expression.

const variableName = function(paramGoesHere){
};

That is, this is before you add the content to the function body. (Omg, I am beginning to get this! This is really beginning to click for me! Yayyyyyyy!). 

I have forgotten all of my else/if statements - whyyyyyyyyyyy

And my switch/case stuff. Maybe I haven't really forgotten them. Maybe I am just overcomplicating them in my mind. Or maybe I just need an opportunity to use them? 

Btw. I was working through an exercise on Codecademy as I did this. We were basically trying to build a calculator to calculate whether it was the write day of the week to water a plant or something.

Okay, the next part I got SO WRONGGG.
  • Firstly, I forgot that if statements go in brackets. 
So (I'm sorry for the lack of context) but this is what the first part of my function should've looked like:

const plantNeedsWater = function(day){
    if(day === 'Wednesday'){
    }
}
  • Secondly, I forgot and/or/slash I didn't know that return functions need to be put in a second set of curly brackets - at least when used with if statements...
const plantNeedsWater = function(day) {
    if(day === 'Wednesday'){
        return true;
    }
}

I basically got this all right, expect for I missed out the brackets around day === 'Wednesday' and also the second set of curly brackets around return true

I just kept on getting more and more errors

In this case I put the closing curly brackets in the wrong place in relation to the else statement 😂

const plantNeedsWater = function (day){
    if(day === 'Wednesday'){
        return true;
    } else {
        return false;
}
};

Adam's Examples

I was talking to the wonderful wonderful Adam about function expressions vs. function declarations.

He sent me some really cool examples and I'd really like to share them with you! :

Function Declarations

// Expression i.e. expressing the function someFunc should do something
function someFunc() {
  return 'something'
}
Arrow Functions

// Declaration i.e. declaring the variable as a function called someFunc does something
const someFunc = () => {
  return 'something'
}
Function Expressions 
const someFunc = function() {
  return 'someting'
}

Arrow Functions 

It's funny because I always keep on forgetting to write the function keyword. And now, according to my course, it looks like there is a way to write a function without them! 

I am going to have to come back to them tomorrow/Weds but I am getting SUPER SUPER INTO THEM!

The Webinar

PLOT TWIST!!! I attended a Polish webinar on Front-End Development today.

It was hosted by Krzysiek Dabrowski, of YouCode.pl. It was so SWEET because my mother emailed it to me late last night. After that I couldn't not go. And to be honest I'm so glad that she did because I learned SO MUCH FROM IT! For starters, it was great to see someone talk through all of the front-end from start to finish. Not only did he talk through all of the React, JavaScript, HTML and CSS stuff, he also outlined the way that it all links together with the internet

It was all bits of knowledge I'd heard here and there, and somehow pieced it together, but it was great to hear them linked together at long last!!!

One thing I really learned was about NPM. How amazing is that - that you can use other people's code to build in features - e.g. like a calendar? How come I have never heard of this before? Have I gotten this right, what this is?

Just some really interesting stuff was how he talked about domains/DNS, servers, APIs and all of that stuff - I'd never heard it all linked together like that with the front-end before. (I have probably listed this all wrong anyway. I hope to be able to come back one day and read this, and to know what exactly it was that I was talking about 😂)

I also FINALLY understood that React is primarily used for Native apps - have I gotten that right as well? 💖

But maybe the best OF ALL was learning to describe my (desired) job in Polish - I'd spent ages over Christmas trying to tell my grandmother in Polish what it is that I (want to) do - and now I know the desired word: PROGRAMISTA 💖

Comments

Popular posts from this blog

Hello World

Yosemite

Where To Hide A Star