Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
8 events
when toggle format what by license comment
Jan 28, 2020 at 4:59 comment added Rustem Zinnatullin Really? This solution seems too weird for me, because toString() method may be overridden and may throw an exception (due to some specific implementation), and your check will not work for sure. Main idea is that you shouldn't call methods that are not related to what you want to get. I'm not even talking about unnecessary overhead related to the toString method. Downvoting.
Aug 15, 2019 at 9:15 history edited Noris CC BY-SA 4.0
added 1 character in body
Jan 25, 2019 at 11:02 comment added sarimarton The idea is still usable. x === String(x) is safe and works.
Nov 6, 2017 at 20:54 comment added user5672998 this is wrong: you can't blindly call .toString on any values; try if the x to be checked is null or undefined, your code throw exception
Jun 1, 2015 at 9:11 comment added MrWhite @MuhammadUmer Yes, it converts it into a string but then checks for identity against the original value, which will only be True if the original value is also a string.
May 27, 2015 at 0:13 comment added Muhammad Umer this doesn't checks if it's a string. It makes into a string, lots of things have toString() function
Feb 25, 2015 at 15:17 review Late answers
Feb 25, 2015 at 15:18
Feb 25, 2015 at 15:00 history answered Noris CC BY-SA 3.0