Strange. He talks about "__proto__" and "prototype". I've been reading JavaScript: The Definitive Reference (O'Reilly, 2007) and it does not mention "__proto__" at all. It explains that "prototype" is a property of ALL objects; whereas Misko states in the video that "prototype" is only defined for functions. In reading "JavaScript: The Good Parts", page 21, the first sentence under the heading "Prototype" says "Every object is linked to a prototype object from which it can inherit properties"
"Someone please tell him javascript ain't supposed to be Java."
I couldn't agree more. He kept calling certain things "problems" where in fact the problem was that he expected JS to behave like Java. His "workarounds" are actually the way it's supposed to be done in JS. I could say the same thing about Java, calling the massive code just to create a binding a problem ... but I don't because there's a reason why it's done that way in Java, & a reason why JS is done differently.
I think one thing missing when explaining the Function Closures was that the function will remember its environment in which they were defined.
So the function binds to its scope at the moment of definition rather then to the current variables and their values found in the scope during execution.
That's why the counter and prefix behave little bit like static variables.
I think this makes understanding closures bit more easier... unless I mixed up something terribly
window isn't the default 'this' in all cases, it's implementation specific, js on the serverside (V8/node for instance) doesn't have a window as global context.
fix previous comment: o.__proto__ can't always be swapped for o.prototype; if you think of a function as a class, then __proto__ is on the instance and prototype is on the class
No, you're right that "this" isn't always "window", but it is the root environment variable whatever that is. For a browser it's windows. for server js frameworks it's "process" or "server" etc ... depending on the framework.
"if you think of a function as a class, then __proto__ is on the instance and prototype is on the class"
I think that's what he meant by saying only functions have prototypes ... all objects have prototypes but only functions requires you to associate the prototype.__proto__ with the .prototype of the class. I think he spent way too much time of __proto__ since the "new" constructor takes care of it for you and it's better practice to avoid __proto__ due to dependencies.
Oops my finger slipped.
JavascriptHacker 1 month ago
thanks for talking about the actual programming language without using alert() boxes within the first 15 seconds. Its a YouTube first!
evhwolfgang2003 4 months ago
Comment removed
PawelWysocki 5 months ago
Comment removed
PawelWysocki 5 months ago
it's good to take advantage of the advantage.
PawelWysocki 5 months ago
Misleadingly labelled.
oscarcollinga 8 months ago
puta q pariu
lampadasled 8 months ago
what do i do whenever i reload my page is get an error:document.body is null anyone can reply to this and tell me what to do?
playstationman2 9 months ago
I know him, he's the crazy guy who does crazy things!
JackBovine 9 months ago
I know him, he's the crazy guy who crazy things.
JackBovine 9 months ago
thanks
TheDark12321 10 months ago
function orgy @44:44
roshanvid 10 months ago
function hello() alert("Hello");
d1995a3 10 months ago
Strange. He talks about "__proto__" and "prototype". I've been reading JavaScript: The Definitive Reference (O'Reilly, 2007) and it does not mention "__proto__" at all. It explains that "prototype" is a property of ALL objects; whereas Misko states in the video that "prototype" is only defined for functions. In reading "JavaScript: The Good Parts", page 21, the first sentence under the heading "Prototype" says "Every object is linked to a prototype object from which it can inherit properties"
win32mfc 11 months ago
are browsergames hackable?
DictatorGBb 11 months ago
Unlike other videos of the Google tech talks I have seen so far, this one was boring. But thanks for sharing the knowledge anyway.
abalde2 1 year ago
Someone please tell him javascript ain't supposed to be Java.
(dont know why do still program with this shiit...)
Raizdecimal 1 year ago
@Raizdecimal
"Someone please tell him javascript ain't supposed to be Java."
I couldn't agree more. He kept calling certain things "problems" where in fact the problem was that he expected JS to behave like Java. His "workarounds" are actually the way it's supposed to be done in JS. I could say the same thing about Java, calling the massive code just to create a binding a problem ... but I don't because there's a reason why it's done that way in Java, & a reason why JS is done differently.
davea0511 6 months ago
I think one thing missing when explaining the Function Closures was that the function will remember its environment in which they were defined.
So the function binds to its scope at the moment of definition rather then to the current variables and their values found in the scope during execution.
That's why the counter and prefix behave little bit like static variables.
I think this makes understanding closures bit more easier... unless I mixed up something terribly
spamero2 1 year ago 12
@spamero2 Hello there, that is a good point. I was thinking the same way, even though I am new to JavaScript, but I know many programming laguages.
bacharyou1 1 year ago
Comment removed
spamero2 1 year ago
window isn't the default 'this' in all cases, it's implementation specific, js on the serverside (V8/node for instance) doesn't have a window as global context.
fix previous comment: o.__proto__ can't always be swapped for o.prototype; if you think of a function as a class, then __proto__ is on the instance and prototype is on the class
webr3 1 year ago
@webr3
No, you're right that "this" isn't always "window", but it is the root environment variable whatever that is. For a browser it's windows. for server js frameworks it's "process" or "server" etc ... depending on the framework.
davea0511 6 months ago
@webr3
"if you think of a function as a class, then __proto__ is on the instance and prototype is on the class"
I think that's what he meant by saying only functions have prototypes ... all objects have prototypes but only functions requires you to associate the prototype.__proto__ with the .prototype of the class. I think he spent way too much time of __proto__ since the "new" constructor takes care of it for you and it's better practice to avoid __proto__ due to dependencies.
davea0511 6 months ago
notes
spec for 'JS' is ECMAScript-262 v3 (doesn't include DOM etc)
everything is 'like' and Object (not everything *is* an Object)
instanceof ClassName works like any other language.
o.__proto__ can be swapped for o.prototype
js is not statically typed lang
first arg of .call() is 'this' instance to call it function on
use ParentClassName.call( this, args ) to call parent constructors.
+ is concatenation operator on strings
semi colon terminations are not specifically needed, compiler auto adds
webr3 1 year ago