Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object.create = function (proto) {
- function F () {}
- F.prototype = proto
- return new F()
- }
- function mockNew (constructor, ...args) {
- const isPrimitive = result => {
- if (result instanceof Object === true) {
- return true
- }
- return false
- }
- const o = Object.create(constructor.prototype)
- const result = constructor.apply(o, args)
- return isPrimitive(result) ? o : result
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement