Permalink
Browse files

Finally get around and start fixing some issues

  • Loading branch information...
BonsaiDen committed Jan 26, 2012
1 parent 98a1f31 commit 01fe309ec1828a99a91b1eb2d939d8f07387155e
Showing with 13 additions and 5 deletions.
  1. +2 −0 doc/en/core/undefined.md
  2. +1 −1 doc/en/function/constructors.md
  3. +6 −4 doc/en/function/scopes.md
  4. +4 −0 doc/en/object/hasownproperty.md
View
@@ -19,11 +19,13 @@ overwritten.
Some examples for when the value `undefined` is returned:
- Accessing the (unmodified) global variable `undefined`.
+ - Accessing a declared *but not* yet initialized variable
- Implicit returns of functions due to missing `return` statements.
- `return` statements which do not explicitly return anything.
- Lookups of non-existent properties.
- Function parameters which do not had any explicit value passed.
- Anything that has been set to the value of `undefined`.
+ - Any expression in the form of `void(expression)`
### Handling Changes to the Value of `undefined`
@@ -4,7 +4,7 @@ Constructors in JavaScript are yet again different from many other languages. An
function call that is preceded by the `new` keyword acts as a constructor.
Inside the constructor - the called function - the value of `this` refers to a
-newly created `Object`. The [`prototype`](#object.prototype) of this **new**
+newly created object. The [prototype](#object.prototype) of this **new**
object is set to the `prototype` of the function object that was invoked as the
constructor.
View
@@ -2,7 +2,7 @@
Although JavaScript deals fine with the syntax of two matching curly
braces for blocks, it does **not** support block scope; hence, all that is left
-is in the language is *function scope*.
+in the language is *function scope*.
function test() { // a scope
for(var i = 0; i < 10; i++) { // not a scope
@@ -213,12 +213,14 @@ being callable, they must first be evaluated.
) // and return the function object
() // call the result of the evaluation
-There are other ways for evaluating and calling the function expression; which,
+There are other ways for evaluating and directly calling the function expression; which,
while different in syntax, do behave the exact same way.
- // Two other ways
- +function(){}();
+ // A few other styles for directly invoking the
+ !function(){}()
+ +function(){}()
(function(){}());
+ // and so on...
### In Conclusion
@@ -44,6 +44,10 @@ necessary to use an *external* `hasOwnProperty` in order to get correct results.
// Use another Object's hasOwnProperty and call it with 'this' set to foo
({}).hasOwnProperty.call(foo, 'bar'); // true
+ // It's also possible use the hasOwnProperty property from the Object property for this purpuse
+ Object.prototype.hasOwnProperty.call(obj, 'bar'); // true
+
+
### In Conclusion
When checking for the existence of a property on a object, `hasOwnProperty` is

0 comments on commit 01fe309

Please sign in to comment.