508 karma · joined November 28, 2012
> true == 1
-> true
> false == 0
-> true
Do you get something different? Or is the game claiming something different? if (Number(myNum) === 2) {}
For me this also extends to using `Boolean(val)` instead of `!!val`, etc.; though I understand the appeal of those nifty one-liners, I think they cause confusion in many places and don't communicate intent nearly as well.Am I way off base here?
1. create a new empty object; call it `newObj`
2. call the constructor using `newObj` as its `this` context, so that `this.a = 1` is effectively `newObj.a = 1`
3. if the constructor has a `prototype` property defined, invoke `newObj.__proto__ = myconstructor.prototype` to establish the prototype chain on the new object
The critical distinction here is between `constructor.prototype` and `object.__proto__`. For exactly this reason, it bothers me a bit that the article uses `Prototype`, with a capital "P", to mean "the thing that `object.__proto__` points to". This is completely different from the `prototype` (small "p") property of a constructor, which is essentially just a holding place for the `__proto__` property of any objects created by calling this constructor with the `new` keyword.Hopefully that all made sense!
let vertebrate = {hasSpine: true},
mammal = {hasHair: true},
dog = {sound: 'bark'};
sparky = {name: 'Sparky'},
jumbo = {name: 'Jumbo'};
mammal.__proto__ = vertebrate;
dog.__proto__ = mammal;
sparky.__proto__ = dog;
jumbo.__proto__ = dog;
console.log(sparky.hasSpine); // true
console.log(jumbo.hasHair); // true
console.log(sparky.sound); // 'bark'
console.log(jumbo.name); // 'Jumbo'
When you access `sparky.hasSpine`, the JS engine first checks whether `sparky` has an "own property" called `hasSpine`. It doesn't, so it checks `sparky.__proto__.hasSpine`, which is the same as `dog.hasSpine`. No luck, so it checks `sparky.__proto__.__proto__.hasSpine` (i.e. `mammal.hasSpine`), and finally `sparky.__proto__.__proto__.__proto__.hasSpine` (i.e. `vertebrate.hasSpine`), which resolves to `true`.This entire structure of objects linked through their `__proto__` property is what we call the "prototype chain". Does that answer your question?
In my (very personal) opinion, an HTML tag or attribute, and more generally a feature of any design/development framework, should be considered possibly harmful if it:
- presents possible security problems; for examples, consider some of the points listed here: https://html5sec.org/
- promotes poor usability or accessibility; e.g. interactive tooltips with links or controls in them, for example, are quite difficult to make accessible, and I wouldn't want an HTML <tooltip> tag without a lot of discussion about accessibility
- promotes anti-patterns; e.g., at this point I think <marquee>-style scrolling informational text is an anti-pattern in a web context, since it can the text much harder to read, especially on small screens
Of course, none of these concerns should lead to immediate removal of a thing as soon as they're pointed out, but they should be discussed and considered. It's a cost-benefit analysis: what does this feature actually buy us that isn't easily achievable with other features, what problems is it causing and how severe are they, and are the benefits worth the problems?
As for <menu>, my guess, though I haven't been able to find the actual discussion, is that it was removed because its semantics are somewhat in conflict with <nav>, and probably its most common use was custom context (aka "right-click") menus, which bring a lot of accessibility problems with them. I don't know that I agree with the decision to remove it altogether, since I think its use to semantically identify and group web application controls is very valuable and not covered by any other tags (though I'd love to be corrected), but I do think that context menus, which to me seems like the most common use for the <menu> tag, are a very problematic design element. Again, it's a balance; is it worth the problems it causes? I guess the authors decided it wasn't.
(Just to reiterate, I don't know why <menu> was removed, I'm just guessing. If anyone can find any of the discussions about <menu> and the problems with it, I'd love to read more.)
1: https://twitter.com/madewithARKit/status/880815805281300480 2: https://twitter.com/madewithARKit/status/880056901987254272 3: https://www.youtube.com/watch?v=z7DYC_zbZCM 4: https://twitter.com/madewithARKit/status/880744158423658497 5: http://newatlas.com/google-translate-update/35605/
This is a substantial oversimplification of course (there are many more factors involved than how fast the ball is growing in the visual field), but I think the point is clear enough. I doubt there's any trigonometry happening in the brain's circuitry; it seems much more plausible to me that the brain is really good at remembering how it felt in previous circumstances, recognizing how those remembered circumstances relate to the current one, and trying to adjust.
As I understand it, this is actually a significant debate in cognitive science, philosophy of mind, and related fields. One prominent proponent of a view like the one I've expressed here, that the brain doesn't require or use heavy math to do things like catch flying objects but rather acquires the ability over time through experience, is John Searle. He is known for using the example of his dog's ability to catch a ball that's bounced off a wall when discussing and arguing against theories of mind that propose that all unconscious processes must be following algorithms or rules (like running through computations to figure out how to catch a ball). Here's a quote of his from the BBC program Horizons (quote found in "New Technologies in Language Learning and Teaching", issue 532, on page 37 [1]):
If my dog can catch a ball that's bounced off the wall, that may be
just a skill he's acquired. The alternative view (the pro-AI view)
would say: "Look, if the dog can catch the ball it can only be
because he knows the rule: go to the point where the angle of
incidence equals equals the angle of reflection in a plane where the
flatness of the trajectory is a function of the impact velocity
divided by the coefficient of friction" - or something like that.
Now, it seems to me unreasonable to think that my dog really *knows*
that. It seems to me more reasonable to suppose he just learns how
to look for where the ball is going and jumps *there*. And a lot of
our behavior is like that as well. We've acquired a lot of skills,
but we don't have to suppose that, in order to acquire these skills,
the skills have got to be based on our mastery of some complex
intellectual structure. For an awful lot of things, we just *do* it.
[1] https://books.google.com/books?id=fWQhj0HVCbUC&pg=PA37&lpg=P...In case anyone's curious, it was Bo Burnham in a Conan interview: https://www.youtube.com/watch?v=q-JgG0ECp2U
Is there something I'm missing that mitigates this intuition? Does this language (or, for that matter, the demo language you wrote for your class) ignore leading or trailing whitespace inside square brackets? What about excess whitespace between words (that is, whitespace beyond a single space or tab)? If so, if indeed leading/trailing/excess whitespace is collapsed inside of square bracket delimited strings, how would I create a string with leading or trailing whitespace or extra space between words if I wanted to?
Honest questions; don't mean to criticize, just eager to learn.
1: https://en.wikipedia.org/wiki/Index_notation#Two-dimensional...