This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
JSBool JS_MakeStringImmutable(JSContext *cx, JSString *str);
||A context. Requires request. In a
||The string to operate on.
A string's characters can never be changed, but SpiderMonkey uses two string optimization techniques behind the scenes:
- A growable string (see
- A dependent string (see
JS_NewDependentString) is a substring of another (growable, dependent, or immutable) string. In memory it is represented as a pointer to the other string and a pair of integers for the substring's starting point and length, rather than as a separate copy of all the characters. This makes the
substringoperation, and regular expression matches, faster.
JSString. These changes are not atomic. Therefore such strings must not be used by more than one thread at a time. Applications must call
JS_MakeStringImmutable before sharing a
After a successful call to
JS_MakeStringImmutable, subsequent calls to
JS_GetStringCharsZ on the same string are guaranteed to succeed, and subsequent calls to
JS_GetStringChars on the same string are guaranteed to return a null-terminated string.