object_to_string.js output to readme

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-07-19 02:00:01 +00:00
parent 675244d8f7
commit 224fae82e1
2 changed files with 25 additions and 0 deletions

View File

@@ -19720,6 +19720,24 @@ Examples:
** link:rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js[] Question: https://stackoverflow.com/questions/30441025/read-all-text-from-stdin-to-a-string
* `class`
** link:rootfs_overlay/lkmc/nodejs/object_to_string.js[]: `util.inspect.custom` and `toString` override experiment: https://stackoverflow.com/questions/24902061/is-there-an-repr-equivalent-for-javascript/26698403#26698403
+
Output:
+
....
util.inspect
my type is MyClassUtilInspectCustom and a is 1 and b is 2
console.log
my type is MyClassUtilInspectCustom and a is 1 and b is 2
toString
[object Object]
util.inspect
MyClassToString { a: 1, b: 2 }
console.log
MyClassToString { a: 1, b: 2 }
toString
my type is MyClassToString and a is 1 and b is 2
....
===== NPM