I'm taking advantage to our free udemy access.

I just finished watching JavaScript: Understanding the Weird Parts by Anthony Alicea. - https://www.udemy.com/course/understand-javascript/

There's already a detailed summary - https://github.com/jasonbaciulis/javascript-understanding-the-weird-parts but I want to make my own because this is my one way of learning, writing about it.

One thing I've learned from this course is there is no right or best way. What matters is what makes the most sense to me.

There are some parts of the course that don't make sense to me, for now. And I will not include those parts because I just can't simply explain it very well. It could just lead to a chain of confusion in the end. But what matters to me for now is I know these exist in JavaScript and understand when to use it.

The history:

JavaScript was named JavaScript to attract Java developers because Java language was popular at that time (1995). (Marketing strategy)

There is no business relation between the two. JavaScript was created by Brendan Eich at Netscape while Java was originally developed by James Gosling at Sun Microsystems.

In JavaScript:

undefined and not defined are not the same

undefined - means the variable has not been set yet

JavaScript sets all variables to value undefined.

not defined - simply means you do not declare the variable

It means it didn't find any initialization of a.

It doesn't matter where the code or function is physically written, it has something to do with when you invoke them or call/run the function.

Variables can hold different types of values because it's all figured out during execution. (dynamic typing)

var isNew = true;
isNew = 'yup!';
isNew = 1;

Functions are objects.

Everything you can do with other types you can do with functions. Assign them to variables, pass them around, create them on the fly.

In other programming languages, you can't do like this.

An example of a property attached to a function. Just like you could attach a property to an object.

Because functions are objects, you can return function as a value.

You can pass a function as a parameter to another function then use it.

All primitive types are passed by value and all objects, even parameters are passed by reference.

In some other programming languages, you can decide whether something is passed by value or by reference. But in JavaScript, you don't have that option.

primitive --- by value

objects --- by reference

Arrays are collections of anything.

We can immediately invoke a function expression.

using a function expression

using an immediately invoke function expression

Any object that we create with a function, we can add feature to all of those objects at once by using the prototype property.

You can do pure prototyping inheritance. This simply makes objects and then creates objects from them pointing to other objects as their prototype. If you want to define a new object, simply create a new object. That will be the basis of others.

Everything is an object.

even null

Class in other programming languages is not an object, it's a definition, a template that tells you what an object should look like and you will not get the object unless you use the new keyword.

But in JavaScript even though it's adding the class keyword, it's still doesn't have class in that sense.

Because this is an object in JavaScript.

class Person {
    constructor(firstname, lastname){
        this.firstname = firstname;
        this.lastname = lastname;
        return 'Hi' + firstname

We're creating an object out of the Person object.

var john = new Person('John', 'Doe');