Quizz: Object-Oriented JavaScript (PartII)
Oct 08, 2009 | English | By Crysfel | No Comments | Leer en EspańolThis is the second part of the third chapter’s quizz. In this quizz we cover the tutorials: Creating objects and public methods, Private methods and privileged methods, Packages and namespace and Inheritance in JavaScript. If you don’t remember about this concepts I suggest you to study them before taking this quizz. Good luck!
Excellent! You got the highest grade:
You had a few questions wrong, but you passed with:
I am sorry, you did not get the minimum grade, your grade is:
In JavaScript the functions are objects.
- True, the functions are objects because they have properties and methods.
- False, the functions are routines or methods, not objects.
What is the correct way to create an object?
- Only using the keyword “Object”.
- We can use the braces “{property:value}” or the keyword “Object”, even a function.
- JavaScript is not a object oriented language therefore we can’t create objects.
How do you create objects using a constructor function?
- With the keyword “class”.
- Using an “instance of” to create the required object.
- Applying a “new” to the constructor function of the object. (new Person();)
- It’s impossible to create objects in JavaScript
How can we define a public method?
- Prefixing the keyword “public” to the method.
- Using the keyword “visible”.
- Using the property “prototype” of the constructor and adding it to the method.
- None of the above.
Is it possible to create private variables and methods in an object?
- Of course it is possible.
- No, that’s not possible.
According to the following code, what is the result after being executed?
var User = function(options){
this.user = options.user;
function sayHi(){
console.debug('hi people!');
}
}
var u = new User({name:'Crysfel'});
u.sayHi();
- The code displays the message “hi people!” in the Firebug’s console.
- An error is generated when executing the method sayHi() because it’s a private method.
According to “Douglas Crockford”, what are the privileged methods?
- They’re the same as the public methods.
- They’re methods that can make Ajax calls to the server.
- They’re public methods that have access to private properties.
- I have no idea who that person is or his contributions.
When are the privileged methods created?
- This methods are created randomly in all the objects of JavaScript.
- This methods are created dynamically at runtime because they are within the constructor.
- They’re created in the same way as the public methods.
- None of the above.
How can we create a “package” (namespace)?
- Using the keyword “package” at the beginning of our code.
- It’s impossible to create a “package” in JavaScript.
- Creating objects inside of other objects (com.quizzpot = {}).
- Writing code inside of an object called “namespace”.
What are the issues we can run into when we don’t use a good “namespace”?
- We can easily delete or overwrite our teammate’s code.
- Issues with the compatibility of third-party libraries.
- We can overwrite variables in memory and get unwanted and hard-to-debug results.
- All of the above.
How do you create “packages” or “namespace” with ExtJS?
- Ext.namespace(‘package.we.need’) or Ext.ns(‘package.we.need’)
- Ext.package(‘package.we.need’)
- Namespace(‘package.we.need’) or Package(‘package.we.need’)
If you are reading this in your email or RSS reader, please go to the Quizz section in order to get your score.






