question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object.prototype.toString() is overridden and behaves incorrectly

See original GitHub issue

After updating to version 0.9, the Object.prototype.toString.call( undefined ) returns [Object Window] instead of [Object Undefined] when the strict mode isn’t turned on.

The root of this bug is caused by this line:

https://github.com/angular/zone.js/pull/734/files#diff-7cf54420c5bf443f7d3575ad72ac1de3R44

where this refers to the Window in non-strict mode.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:24 (8 by maintainers)

github_iconTop GitHub Comments

10reactions
graphicsxpcommented, Jun 27, 2019

When this fix will be released through npm ?

6reactions
cristhiankcommented, May 30, 2019

I found two workarounds:

1- Add the .js to the import in the pollyfills.ts in the Angular app:

image

2- Disable the toString patching as specified in:

https://github.com/angular/zone.js/blob/master/MODULE.md

I added the following to the pollyfills.ts in the Angular app:

__Zone_disable_toString = true; // Zone will not patch Function.prototype.toString image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object.prototype.toString() is overridden and behaves incorrectly
After updating to version 0.9, the Object. prototype. toString. call( undefined ) returns [Object Window] instead of [Object Undefined] when the strict mode ......
Read more >
Why does `Object.prototype.toString` always return `[object *]`?
This is a correction that was made in the ES5.1 spec. Prior to ES5, passing null or undefined to toString always caused the...
Read more >
Object.prototype.toString() - JavaScript - MDN Web Docs
The toString() method returns a string representing the object. This method is meant to be overridden by derived objects for custom type ...
Read more >
Chapter 17. Objects and Inheritance - Exploring JS
We override a method in Super.prototype by adding a method with the same name to Sub.prototype . methodB is an example and in...
Read more >
The-Principles-of-Object-Oriented-JavaScript - Javascript - 19
The primitive wrapper types override valueOf() so that it returns a string ... of this problem involves adding enumerable proper- ties to Object.prototype....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found