Skip to content

Instantly share code, notes, and snippets.

@Zirak
Created January 26, 2018 19:24
Show Gist options
  • Save Zirak/0af0f773707258dca3044817d903de5d to your computer and use it in GitHub Desktop.
Save Zirak/0af0f773707258dca3044817d903de5d to your computer and use it in GitHub Desktop.
// Pop quiz! What gets logged?
var o = {
[console.log('before')]: 4,
foo: (function () {
console.log('nope :(');
throw 'nope'
})(),
[console.log('after')]: 4
};
//--------------\\
(function (){}).name; // ''
var Foo = function () {};
var f = new Foo();
f.constructor.name; // '' or 'Foo'?
//
var Bar = Foo;
var b = new Bar();
b.constructor.name; // '' or 'Foo' or 'Bar'?
//
(function (Foo) {
return (new Foo).constructor.name;
})( function() {} );
//
// and how about:
var o = {
Foo: function () {}
};
(new o.Foo).constructor.name;
//--------------\\
// Pop quiz: What'll this do?
var cull = Object.create(null);
var obj = {};
obj[cull] = 4;
//--------------\\
// Pop quiz: What does this do?
class Foo {
constructor() {
console.log('foo');
}
}
class Bar extends Foo {
constructor() {
super();
super();
}
}
new Bar();
//--------------\\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment