Both method: function() {} and method() {} are valid ways to define a method inside an object.
13.
What is the output of the following code? var person = { name: "Alice", greet: function() { return "Hello, " + this.name; } }; console.log(person.greet());
An IIFE is created using (function() { alert("IIFE"); })();.
15.
What will be the output of the following code? var counter = (function() { var count = 0; return function() { return ++count; }; })(); console.log(counter()); console.log(counter());