InterviewHubPRO
Section Overview
Q264

Question 264 of 521

Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

51%
JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

What happens If I pass string type for getPrototype method

In ES5, it will throw a TypeError exception if the obj parameter isn't an object. Whereas in ES2015, the parameter will be coerced to an Object.

javascript
  // ES5
  Object.getPrototypeOf("James"); // TypeError: "James" is not an object
  // ES2015
  Object.getPrototypeOf("James"); // String.prototype