Read about javascript string concatenation operator, The latest news, videos, and discussion topics about javascript string concatenation operator from alibabacloud.com
ToPrimitive (String. however, if this object is a Boolean, Number, or String object instance, its valueOf () will return an original value (the original value before being packaged by this object ). the two operations are performed as follows:
• ToPrimitive (Number) returns the return value of the valueOf () method of the object (the original value before being packaged) and the result after the ToString
Comparison of array and string methods in javascript, javascript Array
Previous
Strings have many similarities with arrays. They have many methods and have a high similarity. However, they differ that strings are immutable values, so they can be viewed as read-only arrays. This document compares the methods similar to strings and arrays.
Indexable
ECMAScript5 def
several methods. The simplest is to enclose a group of characters in quotation marks and assign them to a string variable. Var myStr = "Hello, String! "; Double quotation marks or single quotation marks can be used to enclose strings. However, note that a pair of quotation marks defining strings must be the same and cannot be mixed. Declarations such as var myString = "Fluffy is a pretty cat. '; are invali
During the development of the script, a large string is often combined to output according to a rule. For example, when writing a script control to control the appearance of the entire control of the HTML tag output, such as Ajax in the server side of the return value after the dynamic analysis of the creation of HTML tags, but here I do not discuss the specific application of splicing strings, I just want to discuss the efficiency of splicing here.
quotes that are defined as strings must be the same and cannot be mixed.
like var myString = "Fluffy is a pretty cat." Such a statement is illegal.
Two types of quotation marks are allowed, making certain operations easier, such as embedding one into another:
document.write ("
We created several strings in the script above, but in essence, they are not real string objects, they are exactly the values of the str
cannot be mixed.like var myString = "Fluffy is a pretty cat." Such a statement is illegal.Allowing the use of two quotes makes some operations simple, such as embedding one into another:
Copy Code code as follows:
document.write ("
We created several strings in the above script, but in essence they are not real string objects, and they are, to be exact, values of string types. To crea
the same and cannot be mixed.like var myString = "Fluffy is a pretty cat." Such a statement is illegal.Allowing the use of two quotes makes some operations simple, such as embedding one into another:document.write ("
we created a few strings in the script above, but in essence they are not real string objects, they are, to be exact, values of string types. To create a
the same and cannot be mixed.like var myString = "Fluffy is a pretty cat." Such a statement is illegal.Two types of quotation marks are allowed, making certain operations easier, such as embedding one into another:document.write ("We created several strings in the script above, but in essence, they are not real string objects, they are exactly the values of the string type. To create a
cannot be mixed.like var myString = "Fluffy is a pretty cat." Such a statement is illegal.Allowing the use of two quotes makes some operations simple, such as embedding one into another:document.write ("
we created several strings in the above script, but in essence they are not real string objects, and they are, to be exact, values of string types. To create a strin
"
Console.log (num.tostring (2));//"1010"
2.String (): Applicable to all types, follow these rules
If the value has the ToString () method, call the method (without parameters) and return the corresponding resultReturns "NULL" if the value is nullReturns "Undefined" if the value is undefined
Example
A string is a set of immutable ordered sequences of 16-bit values, each of which is usually from a U
are defined as strings must be the same and cannot be mixed.like var myString = "Fluffy is a pretty cat." Such a statement is illegal.Two types of quotation marks are allowed, making certain operations easier, such as embedding one into another:document.write ("We created several strings in the script above, but in essence, they are not real string objects, they are exactly the values of the string type. T
value before being packaged by this object ). the two operations are performed as follows:
• ToPrimitive (Number) returns the return value of the valueOf () method of the object (the original value before being packaged) and the result after the ToString () operation.• ToPrimitive (String) returns the return value of the toString () method of the object (the return value of the ToString () operation on the original value before the object is packaged
original value (the original value before being packaged by this object ). the two operations are performed as follows:
• ToPrimitive (Number) returns the return value of the valueOf () method of the object (the original value before being packaged) and the result after the ToString () operation.
• ToPrimitive (String) returns the return value of the toString () method of the object (the return value of the ToString () operation on the original valu
Toprimitive (String). But if this object is a Boolean, Number or an object instance of string, its valueof () returns an original value (the original value before the object is wrapped). Then these two operations are performed as follows:
toprimitive (number) Returns the result of the return value of the object's ValueOf () method (the original value before being wrapped) after the ToString () operation.
1. How to connect strings? First, let's review the two common methods of string connection:1.1 Use the String concatenation operatorCommon languages (such as Java, C #, and PHP) all have string Concatenation Operators, and Javascript
Document directory
3. Conclusion
1. How to connect strings?
First, let's review the two common methods of string connection:1.1 Use the String concatenation operatorCommon languages (such as Java, C #, and PHP) all have string Concatenation Operators, and
This article describes the attributes and methods of String objects of JavaScript native objects. This article describes the attributes and methods of length, charAt (), charCodeAt (), concat (), and indexOf (), lastIndexOf () and other method attributes. For more information, see
Length
The length attribute returns the number of characters in a string.
Length i
required. One or more string objects that will be concatenated to a string.Tip: Note that it is usually easier to use the "+" operator for concatenation of strings.
Copy Code code as follows:
var str1= "Hello"
var str2= "world!"
document.write (Str1.concat (STR2))
The output is:Hello world!
10. The FontColor () method is used to display
this extension, this method may not be found. In addition, calling the prototype extension method is a little slower than calling the method directly, because JavaScript will first try to find it in the method of the String object itself, and then find the prototype method of the String; in addition, in the future, the extended method (such as repeat) may become
string.
The concat () method converts all its arguments to strings and then sequentially connects to the tail of the string stringobject and returns the concatenated string. Please note that the Stringobject itself has not been changed.
Note that it is highly recommended that you use the "+" operator for
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.