Explanation
Last updated
Was this helpful?
Last updated
Was this helpful?
This example explains what partial primitive value and the exact return type means in the string
object.
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.
To create primitive value of 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.
All the parts that make up the primitive value of the 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".