Skip to content

Instantly share code, notes, and snippets.

@oliverswitzer
Created January 22, 2014 21:55
Show Gist options
  • Save oliverswitzer/8568134 to your computer and use it in GitHub Desktop.
Save oliverswitzer/8568134 to your computer and use it in GitHub Desktop.
What does the following code print to the console?
var person = {
name: "Joe Camel",
age: 42,
status: "dead"
}
console.log(typeof person);
--> Object {name: "Joe Camel", age: 42, status: "dead"}
What does the following code print to the console?
var hat = {
size: "large",
color: "orange"
}
console.log(hat.size);
--> 'large'
What does the following code print to the console.
var teddy_bear = {
texture: "fluffy"
}
console.log(teddy_bear["texture"]);
-->'fluffy'
What does the following code print to the console?
var fat_joe = {
crew: "Terror Squad"
}
fat_joe.crew = "something";
console.log(fat_joe.crew);
//--> 'something'
What does the following code print to the console?
var pen = {};
pen.ink = "blue";
console.log(pen.ink);
// --> 'blue'
What does the following code print to the console?
var walking_dead = {
topic: "zombie apocalypse"
}
console.log(walking_dead["main_character"]);
//--> undefined
What does the following code print to the console?
var bottle = {
contents: function () { return "some fine bubbly" },
color: "green"
}
console.log(bottle.contents());
// --> 'some fine bubbly'
What does the following code print to the console?
var yao = {
self: function () { return this }
}
console.log(yao === yao.self());
//--> true
What does the following code print to the console?
var lebron = {
occupation: "basketball",
introduction: function () {
return "My name is LeBron and I play " + this.occupation
}
}
lebron.introduction();
// --> 'My name is LeBron and I play basketball'
What does the following code print to the console?
var square = {
side_length: 4,
area: function () {
return this.side_length * this.side_length;
}
}
console.log(square.area());
// --> 16
What does the following code print to the console?
var me = {
first_name: "Matthew",
last_name: "Powers",
full_name: function () {
return this.first_name + " " + this.last_name;
}
}
console.log(me.full_name());
// --> 'Matthew Powers'
What does the following code print to the console?
var mug = {
capacity: "10 fluid ounces",
customer_message: function (desired_size) {
if (desired_size > 10) { return "This mug is not large enough for you" };
}
}
console.log(customer_message(13));
// --> 'This mug is not large enough for you
What does the following code print to the console?
function global_function () { return "I can be called anywhere" };
var an_obj = {
something: global_function
}
console.log(an_obj.something());
// --> 'I can be called anywhere'
What does the following code print to the console?
var person = {
age: 32,
address: {
city: "New York",
state: "NY"
}
}
console.log(person.address.city);
//--> 'New York'
What does the following code print to the console?
var golf = {
type: "sport",
clubs: {
high_end: "taylor made",
low_end: "rusty basement clubs"
}
}
golf.clubs.high_end = "callaway";
console.log(golf.clubs.high_end);
// --> 'callaway'
What does the following code print to the console?
var ideal_scene = {
status: "chillin'",
location: "somewhere with good waves",
thoughts: "bling bling"
}
delete ideal_scene.thoughts
console.log(ideal_scene.thoughts);
// --> undefined
Describe the value that the zombie variable is assigned to.
var zombie = new Object();
// --> it is assigned an empty object (an object which inherits from the Null class in JS)
What does the following code print to the console?
var game = { title: "tic tac toe" };
var same_game = { title: "tic tac toe" };
console.log(game === same_game );
// --> false
What does the following code print to the console?
var lyric = { lyric: "right now, aight" };
console.log(lyric === lyric);
// --> true. An object does equal itself
What does the following code print to the console?
var ruff_ryders = {
dmx: {
birthplace: "Mount Vernon, NY"
}
}
console.log(ruff_ryders.lox.birthplace);
// -->TypeError, cannot read 'birthplace' of undefined (lox doesn't exist in ruff_ryders)
What does the following code print to the console?
var ruff_ryders = {
dmx: {
birthplace: "Mount Vernon, NY"
}
}
console.log(ruff_ryders.lox && ruff_ryders.lox.birthplace);
// --> undefined
What does the following code print to the console?
var a = {
x: "y"
}
console.log("x" in a);
// -->
What does the following code print to the console?
var abc = {
zz: "ll"
}
console.log(abc.hasOwnProperty("zz"));
Add a real_name property to the following dmx object with the value "Earl Simmons".
var dmx = {
occupation: "rapper"
}
Add a circumference method to the following circle object that returns the circumference of the circle (Pi equals Math.PI).
var circle = {
radius: 10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment