JavaScript syntax: Difference between revisions

Content deleted Content added
Nelsonkam (talk | contribs)
Number: Improved formatting for better rendering on mobile version.
Tags: Mobile edit Mobile web edit
Nelsonkam (talk | contribs)
String: Improved formatting for better rendering on mobile version.
Tags: Mobile edit Mobile web edit
Line 226:
</syntaxhighlight>
 
You can access individual characters within a string using the <tt>{{mono|charAt</tt>}} method (provided by <tt>{{mono|String.prototype</tt>}}). This is the preferred way when accessing individual characters within a string, because it also works in non-modern browsers:
 
<syntaxhighlight lang=JavaScript>
Line 264:
</syntaxhighlight>
 
It is possible to create a string using the <tt>{{mono|String</tt>}} constructor:
 
<syntaxhighlight lang=JavaScript>
Line 270:
</syntaxhighlight>
 
These objects have a <tt>{{mono|valueOf</tt>}} method returning the primitive string wrapped within them:
 
<syntaxhighlight lang=JavaScript>
Line 278:
</syntaxhighlight>
 
Equality between two <tt>{{mono|String</tt>}} objects does not behave as with string primitives:
 
<syntaxhighlight lang=JavaScript>