tisdag 15 februari 2011

Week 3


  1. In Javascript, functions are first class objects. What does it mean to be a first class object?
First class objects are special types of objects that can do the same things as objects.

  1. Functions and variables share the same namespace. What does this mean and what important implication does this have?
If I have a variable and a function with the same name the program will not work.
          <script type="text/javascript">
                          var test = 1;
                          function test(number) {
                          number = 2;
                          return number;
                          }
                          alert(test());
                         
          </script>
This will not give any output as long as both the function and the variable have the same name “test”.

  1. Douglas Crockford equates Javascript functions with Lambdas, and also mentions that they are a secure construct. Can you do some research and reflect on what he means by 'secure construct'?

  1. Can you explain the concept of a closure.
“The scope that an inner function enjoys continues even after the parent function have returned.”
I got the feeling that this meant that a function within a function does not reset after the “outer” function is done. The inner function goes on until it fulfills it owns conditions.
Looking forward to response on this one, also very curious what others have answered.

  1. What is the difference between a function and a method?
A method is a property that contains a function.

  1. In Javascript there is no implicit type checking of arguments passed to functions. This could lead to bugs if programmers are not careful about what they pass to functions. If you create a function, how would you protect it from well meaning but careless programmers?

    Don't know yet.

  1. Javascript functions have implicit access to something called this. this points to different things depending on how the function was created. Can you explain why we need this, and what it represents in different type of functions.

No, I can’t.


  1. Why doesn't Javascript have a cast operator?
Maybe because JavaScript is clever enough to understand what type the value is, and do not need to be told.

  1. What is reflection and why is it easy in Javascript (you may need to do research to answer this question)?
I don’t know.

Homework 1
Ex. 6.1
Seriously, these exercises from eloquent javascript is so useless that they are not worthy my time. I mean, not even the code in the “solution” give any output in their own console. How am I supposed to learn? And the exercise does not use stuff we learned from the text before the exercise. No, they present new stuff that is needed in the solution. We should not find new stuff in the solution, everything that is needed should be in the text just before the exercise.
I had enough of this now. I was hoping to learn something useful from this course, but with exercises that only work in their own custom made console I just don’t see the point with it.
I have learned a lot more from Google and the Douglas Crockford videos on my own.




glenn.hellquist@gmail.com
webbkraft.com

/*#p2pu-Jan2011-javascript101*/

Inga kommentarer:

Skicka en kommentar