Explanation
Partial primitive value with the exact return type
This example explains what partial primitive value and the exact return type means in the Wrap
string
object.
To create primitive value of Wrap
object there is the need to provide three parameters in order opening
, closing
, and optional content
. They are stored in separate private properties which are accessible with the help of accessors, and because of this, access to parts of the primitive value is achieved. More, each parameter is of a generic type variable that detects the type of given value, and because of this, the exact return type of primitive value and its parts is achieved.
Immutability
All the parts that make up the primitive value of the Wrap
object are immutable because they are accessible only by the get
accessors. There is no possibility to change any part of the primitive value of the quoteTag
object and any try to change e.g. opening
results in the error message "Cannot assign to 'opening' because it is a read-only property".
Object as types
There is possibility to check whether the object is the wrapper
with the help of typeOf()
function. The name of bbCodeWrapper
object cannot be changed in the example below.
Last updated