Imon's Development Studio

Imon's Development Studio

Share

01/11/2023

Difference between `String(value)` constructor & `value.toString()` method

I was wondering what is the difference between `String(value)` constructor & `value.toString()` method for coercing a value to string. Found the solution in stack-overflow. It seems `String()` constructor to some extend do call the `toString()` method albeit through a function. Which allows it to handle `null` & `undefined` value as well. That is not the case for `toString()` method. The image attached shows a `null` value results in null for `String()` constructor & for `toString()` method it throws a TypeError.

The link is following for anyone that wishes to check the original post. https://stackoverflow.com/questions/3945202/whats-the-difference-between-stringvalue-vs-value-tostring

Want your business to be the top-listed Advertising & Marketing Company in Dhaka?
Click here to claim your Sponsored Listing.

Telephone

Address


Mirpur
Dhaka
1206

Opening Hours

Monday 10:00 - 00:00
Tuesday 10:00 - 00:00
Wednesday 10:00 - 00:00
Thursday 10:00 - 00:00
Saturday 10:00 - 00:00
Sunday 10:00 - 00:00