DEV Community

benboorstein
benboorstein

Posted on

3 2

My Raw Notes for the Week of 9-27-2021

In Simpson's thinking, there are three "pillars" of JS:
1) Types/Coercion
    - Primitive Types
        - undefined
        - string
        - number
        - boolean
        - object
            - function
            - array
        - symbol (not used much)
        - null (sort of)
    - Converting Types
        - Number and String:
            - Number + Number = Number <this is the only one of the four in which the '+' means 'mathematical addition' (as opposed to 'concatenation')>
            - Number + String = String
            - String + Number = String
            - String + String = String
        - Truthy and Falsy
            - If we were to coerce a non-boolean value into a boolean, would it be true or false? If true, the value is Truthy. If false, Falsy
            - Falsy values in JS: '', 0, -0, null, NaN, false, undefined. Truthy values in JS: everything else
    - Checking Equality
        - '==' allows coercion (types different)
        - '===' disallows coercion (types same)
2) Scope/Closures
    - FYI:
        - Simpson: Scope is where the JS engine looks for things
    - FYI:
        - Example of what's called a 'function statement' or 'function declaration': function funcDec() {}
        - Example of what's called an 'anonymous function expression': const anonFuncExp = function() {}
        - Example of what's called a 'named function expression': const namedFuncExp = function namedFuncExp() {}
    - Nested Scope
    - Closure
        - Simpson's definition: "Closure is when a function "remembers" the variables [created] outside of it, even if you pass [or call] that function elsewhere."
3) this/Prototypes
    - this
        - Simpson: "A function's 'this' references the execution context for that call, determined entirely by HOW THE FUNCTION WAS CALLED."
    - Prototypes
        - Function constructors and their interaction with 'this'
    - Class{}
        - using the 'class' keyword as an improved syntax for setting up a Function constructor

Whether a variable is declared but not assigned a value or it's simply never declared, it has a type of 'undefined'.

For 'let v = null', 'typeof v' is 'object'. This is a bug in the JS language which can't be changed now.
For 'v = function(){}', 'typeof v' is 'function'. This is strange because 'function' is a subtype of 'object', but it's not a mistake and it is useful.
For 'let v = [1, 2, 3]', 'typeof v' is 'object'. This makes sense because 'function' is a subtype of 'object'.
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs