JS Basics
Jan Filipowski
Me, myself and I
Goals
Values
Type conversions
Variables
Global variables and constants
window.variable = value
const constant = value
Literals
Numbers
Expressions
Special
Regular expression
Statements
Exceptions
Functions
Objects
Object model
Property lookup in prototypical inheritance (console(o.field))
If property in prototype is method, which uses other property of object it starts looking for it's value from original (first) object, not the current one - prototype.
Consequences - examples
Object construction flow
Assume we have Foo constructor and we want to create object o. Then flow looks like this:
o = new Object()
o.__proto__ = Foo.prototype
o.Foo()
How to pass arguments to prototype constructor
Assume: Bar.prototype = new Foo()
function Bar(name, smth) {
Foo.call(this, name)
this.smth = smth;
}
Setters and getters
No kidding, guys!
Source
KTHXBYE
Questions?