String conversion
String conversion is an operation that transforms a value or representation into its textual string form according to language-defined rules.
JavaScript in Depth
The language process that converts a value to a textual string according to coercion rules.
- How it is used
- Explains textual coercion and its interaction with comparisons, conditions, numeric operations, and performance-sensitive code.
- How deep it goes
- Works through primitive and array results, chained coercion, and repeated runtime cost, while deferring detailed object customization.
- Examples
- Uses String calls, [] == false, conditional execution with [], and numeric sorting of timestamp values.
- What you can do after
- Diagnose surprising coercion results and avoid repeated conversions through type checking or TypeScript.
The Well-Grounded Rubyist, Fourth Edition
String conversion is the derivation of a string or another object representing a string value in a different form.
- How it is used
- Provides object representations for output, interpolation, inspection, and regular-expression troubleshooting.
- How deep it goes
- Explains automatic calls, custom definitions, related methods, array exceptions, and regexp notation without exhaustive API coverage.
- Examples
- Uses irb expressions, a customized Object instance, array output, file output, and regular-expression representations.
- What you can do after
- Apply it via Ruby's to_s, puts, interpolation, inspect, display, and custom representation methods.
Read how The Well-Grounded Rubyist, Fourth Edition explains string conversion →
Python How-To
A string representation is textual output that describes the value or identity of an object.
- How it is used
- Improves object inspection, printed output, formatted display, and interactive console readability for class instances.
- How deep it goes
- Distinguishes __str__ from __repr__, specifies return requirements, and demonstrates both overrides with a Task class.
- Examples
- Uses a Task object with title, description, and urgency fields to demonstrate print, f-string interpolation, str(), repr(), and console display.
- What you can do after
- Build it from scratch by overriding __str__ and __repr__ for readable display and informative instance representations.
Also covered in
- 100 Go Mistakes and How to Avoid Them
- The Quick Python Book, Fourth Edition
- API Design Patterns
- Clojure: The Essential Reference
Related concepts
- number conversionuses · The language process that converts a value to a numeric value according to coercion rules.
- regular expressionproduced by · A regular expression is a formal pattern notation that describes sets of strings and specifies how text can be matched, searched, or transformed.
- __repr__produced by · __repr__ is a Python special method that returns an object’s developer-oriented string representation, ideally unambiguous and suitable for recreating an equivalent object.
- __str__produced by · __str__ is a Python special method that returns an object's informal, human-readable string representation.
Questions about string conversion
What is string conversion?
String conversion is an operation that transforms a value or representation into its textual string form according to language-defined rules.
Which Manning books explain string conversion?
JavaScript in Depth, The Well-Grounded Rubyist, Fourth Edition and Python How-To.
What is string conversion also called?
String conversion is also called string representation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


