Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created January 13, 2020 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save prof3ssorSt3v3/c7832cc14976e8bfd224772615ce0844 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/c7832cc14976e8bfd224772615ce0844 to your computer and use it in GitHub Desktop.
let obj1 = {
a: "this",
b: "is",
c: "an",
d: "object",
e: "literal"
};
let obj2 = new Object(["object", "contructor", "one"]); // new Array("", "", "")
let obj3 = new Object({ an: "object", literal: "again" });
let obj4 = new Object(obj1.a); // new Object("some string") new String("asdfas")
let obj5 = new Object(); //same as new Object(null) or new Object(undefined)
let obj6 = new Object(true); // new Boolean(true)
console.log(
"OBJ1",
obj1,
typeof obj1,
obj1 instanceof Object,
obj1.constructor,
"\n"
);
console.log(
"OBJ2",
obj2,
typeof obj2,
obj2 instanceof Array,
obj2 instanceof Object,
Array.isArray(obj2),
obj2.constructor,
"\n"
);
console.log(
"OBJ3",
obj3,
typeof obj3,
obj3 instanceof Object,
obj3.constructor,
"\n"
);
console.log(
"OBJ4",
obj4,
typeof obj4,
obj4 instanceof String,
obj4.constructor,
"\n"
);
console.log(
"steve",
String("steve"),
new String("steve"),
typeof "steve",
typeof String("steve"),
typeof new String("steve"),
"\n"
);
console.log(
"OBJ5",
obj5,
typeof obj5,
obj5 instanceof Object,
obj5.constructor,
"\n"
);
console.log(
"OBJ6",
obj6,
typeof obj6,
obj6 instanceof Boolean,
obj6 instanceof Object,
obj6.constructor,
"\n"
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment