hjertnes.blog

#

14.11.2017 01:00

Variables

14.11.2017 01:00

There are now three different ways to create a variable in Javascript. There are many different minor differences between the three.

```text
  • When you create a variable with ‘var’ you also add a property to the window object, this is not the case with let or const
  • Var and let are replaceable, const are not; all of them are mutable.
  • Let variables can be local to a block (see example below)
  • ```

    ```text I would stay away from var unless you have a really good reason to use it. Then I always start with a const, and migrate it to a let if I really need to replace it.
    Local scoping with let: ```

    ```text The example above shows how lexical scopinng can work with let. But use it with caution, because it can be confusing for developers that don’t understand the differences between let and var. Example one and three shows how it works without local "scoping" and the one in the middles shows how it works with local scoping. The short version is that you can define variables with the same names in different scopes without them writing over each other. Very useful for variables that don’t need to be available outside and for using the same variable name for all temporary data of a certain type or use. ```

    #

    13.11.2017 01:00

    Being more mindful about what kind of functions you use where

    13.11.2017 01:00

    Let’s talk about arrow functions versus regular functions. I love how much more minimal and elegant arrow functions look. But I think we might need to start being more mindful about what we use where.

    ```text The key difference between the two is that an arrow function shares it’s this with where it is defined, while a function either shares it with the global scope, or the context it is bound to; if you are using strict you have to bind it to something to have a ‘this’ at all. ```

    ```text I see all the time that me and many other developers are using each one for all the wrong reasons. ```

    ```text Use regular functions if you don’t interact with ‘this’ or if you are going to bind it. And use arrow functions if you are going to use the ‘this’ of where it is defined. ```

    ```text A typical place where many people use regular functions where arrow functions is a better option is event handlers in React. And a typical place where people use arrow functions a lot, instead of regular functions, where they are not the best option (because we are lazy) is utility functions. ```

    ```text Be mindful about the differences, and understand what you are doing and why. ```

    Workflow and Pythoninsta.

    13.11.2017 01:00

    I was looking into how to do something really simple using Drafts and Todoist on Saturday.

    The basic idea was that I wanted an easy way to either add or create a new project and then add a series of tasks to it. (First line is the project, and the rest is tasks).

    Well. I thought, this is a perfect opportunity to play around with Workflow. So, I made the damn thing and then I also did it using Pythonista.

    The verdict? It took way shorter time using Pythonista because I know how it works, but I think something like Workflow is the right tool, if you don’t know how to code.

    This is a common thing I often see myself doing. When something is very simple, I almost always end up writing it myself, because then I don’t need to learn all the “jargon” and metaphysics every single system always have.

    The difficult thing is to know when to write it yourself, and when to learn what is already there.

    #

    12.11.2017 01:00

    #

    12.11.2017 01:00

    Anyone tested out Lightroom CC?

    Task Management in 2018

    12.11.2017 01:00

    ```text One of the most important, if not the most important part of a well functioning system for managing the things you have to do is a ever changing system to manage it all. ```

    ```text The system I was happy with in 2010 or in 2012 or 2015 is not the same as what I am happy with today. ```

    ```text I started to notice some eh let’s call them “growing problems” with my pen and paper only system earlier this autumn; the short version: ```

    ```text
  • I forgot to write stuff down
  • I didn’t find some of what I wrote down
  • etc
  • etc
  • ```

    ```text So, I decided to move back to Todoist. Their apps aren’t the best, to say the least. But they do have a good API. So I can get it to do what I need. ```

    ```text Where does pen, paper and all the stuff we love fit into this? ```

    ```text While I don’t currently use pen and paper to mange everything (at the moment) I still use it for a few very crucial tasks. I still use my beloved Leuchtturm1917 dot grid notebook in the planning stage, or when I do a brain dump. And I still use it to map out the most important stuff I need to get done day per day per week. ```

    ```text And I do of course bring my notebook instead of a computer do meetings, like a grown up. ```

    #

    11.11.2017 01:00

    #

    11.11.2017 01:00