Week 10 Quiz

What is the difference between a library and a framework?
Examine the following code and explain to me what is going on?

What Will Print?

Consider the following code:

(function() {
   var a = b = 5;


What will be printed on the console?
What will it print if you were in "strict" mode?

Write a Native method:

Define a repeatify function on the String object/class. The function accepts an integer that specifies how many times the string has to be repeated. The function returns the string repeated the number of times specified. For example:

Should print hellohellohello.


What’s the result of executing this code and why?

function test() {
   var a = 1;
   function foo() {
      return 2;

The problem with this:

What is the result of the following code? Explain your answer.

var fullname = 'John Doe';
var obj = {
   fullname: 'Colin Ihrig',
   prop: {
      fullname: 'Aurelio De Rosa',
      getFullname: function() {
         return this.fullname;


var test = obj.prop.getFullname;

Object Type:

What is a potential pitfall with using typeof bar === "object" to determine if bar is an object? How can this pitfall be avoided?

Same thing?

...This is tricky...

Consider the two functions below. Will they both return the same thing? Why or why not?

function foo1()
  return {
      bar: "hello"

function foo2()
      bar: "hello"