29 lines
1.9 KiB
Org Mode
29 lines
1.9 KiB
Org Mode
* 3 new thing
|
|
** 1
|
|
Javascript has primitive values and primitive data types.
|
|
As far as I know, other languages would consder a string to not
|
|
be a primitive data type, so that was a surprsing one here, but the other data types are:
|
|
String
|
|
number
|
|
boolean
|
|
null
|
|
undefined
|
|
** 2
|
|
While Booleans, Numbers, and Strings are not objects by default, they can become as such by being defined with the /new/ keyword. Though, the end of the objects lesson tells us that we shouldn't do that. Just keep them primitive.
|
|
** 3
|
|
Javascript can make classes by simply writing a function.
|
|
To make the object, then myNewObj = someFunction(); I like that.
|
|
|
|
* 2 interesting
|
|
** 1
|
|
In Javascript, objects appear to be lists that can contain anything.
|
|
I seem to remember that classes were eventually introduced into JavaScript, but classes look quite a bit different, even if they seem to accomplish much of the same thing.
|
|
** 2
|
|
Objects are addresed by reference. So we need to explicitly copy objects (something that always messes with me, I like consistancy. someVar = someOther var should always be a copy, or always be a reference, not either or depending on what it's being set equal to) if we want to have a copy instead of just a pointer. someVar = SomeObj makes someVar a pointer by default.
|
|
** Bonus
|
|
I thought "var" was for global, but no. "var" let's javascript determine the scope. Let forces local. And no keyword means global.
|
|
* 1 unclear
|
|
Why does javascript have special syntax for getters and setters? If anything, it only serves to make it more confusing by making them different from functions.
|
|
|
|
w3schools claims that it provides simpler syntax, but then I may as well access the property directly. If I use the getter to do more than simply set the property value, then it's confusing to think of x = y having some sort of functional result rather than a direct assignment.
|