This article mainly introduces the JavaScript through the dictionary to translate the string translation the method, involves the JavaScript string conversion skill, has certain reference value, the need friend may refer to under
This article illustrates the way JavaScript
In the course of learning JavaScript, you have encountered a lot of operations on arrays and strings. A lot of methods have been summed up before, but when I met my own use, I forgot. Do not forget the method called what name, just forget the method parameters have what, what is returned?Now let's summarize it again:The first is the method of the string:1. Character Method:CHARAT ()---Function: Returns the
This article introduces and analyzes the specific use of string objects in JavaScript, as well as the methods associated with string objects, which make it easier for developers to better handle strings in JavaScript development.1. IntroductionString object that operates on a strin
In JavaScript, you can convert a string value to number in 3 ways:
1. Call number () to convert the string to a value type.2.parseInt ().3.parseFloat ().
Number ()
It is most straightforward to use the number () function to force type conversions on a string. However, this practice has a limitation: if the
One of the built-in features of JavaScript is the string connection, which, if you connect two numbers with ' + ', represents the two number added. However, if used with a string, the second word multibyte after the first character.var num=1+2;console.log (num), var msg= ' hello ' + ' world '; Console.log (msg);for strings, there are many other useful properties
String
A string is one or more characters that are arranged together in single or double quotes.
' ABC '"ABC"
Length Property
The string in JS is similar to an array, and is made up of a single character, so you can use the Length property to get the string
var str = "Hello"Str.length; 5
Some methods commonly use
A. String
Copy Code code as follows:
var language = "JavaScript";
var language = ' JavaScript ';
Strings can be used in double quotes and single quotes, depending on your personal preference.
The string has a length property that can return the number of strings in a variable.
Copy
Problem description
There are some empty string "" when splitting a string using the JavaScript split method, especially when using regular expressions as delimiters.
Related issues
A JavaScript regular expression produces an empty string group when grouping strings?
In
As we all know, advanced browsers can use the Json.parse () API to parse a JSON string into JSON data, slightly defective, and we can use the eval () function.
var str = ' {' name ': ' Hanzichi ', ' age ': ';
var obj = eval (' (' + str + ') ');
Console.log (obj); Object {name: "Hanzichi", age:10}
Do you notice that the STR variable wraps around a bracket when it is passed to eval ()? Why did you do that?
Let's take a look at the definiti
Data structures and algorithms in JavaScript (4): string (BF ),
A string is a finite sequence composed of zero or multiple characters. It is also called a string.
The logical structure of a string is similar to that of a linear table. The difference is that a
position ordinal 2 ( The character of the previous ② parameter Console.log (s.substring (2, 4)); = = CD: Returns the character Console.log (S.substring (-3, 3) from the position ordinal 2 to the position ordinal 3 (the previous one of the ② parameters); ABC: If the parameter is negative, it is processed by the number zero, so this parameter actually returns the position ordinal 0 to the position ordinal 3 character4.14 toUpperCase (): Converts a string
JavaScript Functions provide developers with all the functions they need:
• Concat ()-combines two or more characters to return a new string.
• Indexof ()-returns the index at the first part of a substring in a string. If no match exists,-1 is returned.
• Charat ()-returns the character at the specified position.
• Lastindexof ()-returns the index that appears at
The introduction of a new string literal-template string in ES6, in addition to using inverted quotation marks ('), means that they do not appear to be any different from ordinary strings. In the simplest case, they are ordinary strings:
Context.filltext (' Ceci n ' est pas une cha?ne. ', x, y);
Context.filltext (' Ceci n ' est pas une cha?ne. ', x, y);
It is called a template
The value of the operation string is common for developers. There are many methods to operate on a string, such as extracting part of the content from a string or determining whether a string contains a specific character. The following JavaScript Functions provide developer
What is JSONJSON (JavaScript Object Notation) is a graceful way to create JavaScript objects. JSON is also a lightweight data interchange format. JSON is very easy for people to read and write, while facilitating machine parsing and generation. JSON is a better solution for exchanging data in Ajax instead of XML.JSON format and syntaxvar jsonobject={property syntax within an object (property names and prope
This article mainly introduces JavaScript data structure and algorithm (four): string (BF), the string is composed of 0 or more characters of the finite sequence, also known as strings, this article focuses on the BF (brute Force) algorithm, the need for friends can refer to the
A string is a finite sequence of 0 or m
JavaScript string cut splitThe most common method of string cutting in JavaScript is split() this function. This function returns an array after the cut.Example:var"hello world";var arr = str.split(" "//用空格切割字符串。alert( arr[0// 输出 helloalert( arr[1//输出 worldThis is relatively simple.SubstringThis is also used to cut str
The escape character \ can escape many characters, such as \ n for newline, \ t for tabs, and the character \ itself to be escaped, so \ \ is the character that \ \.ASCII characters can be #形式的十六进制表示 in \x#, for example:[JavaScript]Plain Text view copy code ?
001
‘\x41‘; // 完全等同于 ‘A‘
You can also use \u### #表示一个Unicode字符:[JavaScript]Plain Text view copy code ?
JavaScript String Object
Let's take a look at an instance of the length of the returned character.
Result is 12
Let's look at an example.
The IndexOf () methodHow to use the IndexOf () method to return the position of the first occurrence of the specified string value.
Okay, let's take a look at a simple introductory tutorial on
Summary of common methods of javascript--stringExample templates:var str = "What is You"var str1 = "sss"var txt = str. method (parameter 1, parameter 2 ...) Console.log (TXT)1.charAt (Index): Returns the string specified in the string according to the indexvar txt = str.charat (5)2.charCodeAt (Index): Returns the ASCII encoding of the specified
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.