1. Define an array object to store a series of values in a separate variable name. We use the keyword new to create an array object. The following code defines an array object named myArray: varmyArraynewArray () or: varshowText []; // creates an array showText. push (helloworld); // Number of push directions
1. Define an array
An array object is used to store a series of values in a separate variable name.
We use the keyword new to create an array object. The following code defines an array obj
Array_keys () functionfunction returns a new array containing all the key names in the array$a=array("Volvo"=>"XC90","BMW"=>"X5","Toyota"=>"Highlander");print_r(array_keys($a));Array ([0] = Volvo [1] = BMW [2] = Toyota)$a=array("Volvo"=>"XC90","BMW"=>"X5","Toyota"=>"Highlander");print_r(array_keys($a,"Highlander"));Array ([0] = Toyota)$a=array(10,20,30,"10");prin
1. What is an array?An array object uses a separate variable name to store a series of values. That is, the array can store all values with a variable name, each of which has its own ID, so it is easy to access any value with the variable name.2. Creating an array(1) General method:var mycars=new Array ();Myarr[0]= "Volvo";Myarr[1]= "BMW";Myarr[3]= "Saab";(2) Concise way:var mycars=new Array ("Volvo", "BMW"
world! I ' m about to learn php! This string is made with multiple parameters. Show variablesThe following example shows how to use the echo command to output variables and strings:Results:Learn Phpstudy PHP at W3cschool.cnmy car is a Volvo Print StatementPrint is also a language structure, you can use parentheses, or you can use no parentheses: Print or print ().Display stringThe following example shows how to use the Print command to output a str
Boolean (logic) can have only two values: TRUE or FALSE. var X=truevar y=false JavaScript Arrays The following code creates an array named cars: var cars=new Array (); cars[0]= "Audi"; cars[1]= "BMW"; cars[2]= "Volvo"; or (condensed array): var cars=new Array ("Audi", "BMW", "Volvo"); or (literal array): Example var cars=["Audi", "BMW", "Volvo"; The array s
code block executes before the condition is tested:Do{X=x + "The number is" + i + "i++;}while (IDon't forget to increase the value of the variable used in the condition, otherwise the loop will never end! Compare for And whileIf you have read the previous chapter about the for loop, you will find that the while loop is much like the for loop. For statement instanceThe loop in this example uses a for loop to display all the values in the cars array:cars=["BMW", "
The definition of an array:Method 1.
Copy Code code as follows:
var mycars=new Array ()
mycars[0]= "Sharejs.com"
mycars[1]= "Volvo"
mycars[2]= "BMW"
Method 2.Define and initialize together:
Copy Code code as follows:
var mycars=new Array ("Saab", "Volvo", "BMW");
Or:
Copy Code code as follows:
var mycars=["Saab", "
case sensitive
[5] The identifier should be in small hump format, the first digit should be the type of data, the common identification is as follows:
Array A-array aitemsBoolean B boolean BiscompleteFloating-point number F float fpriceFUNCTIONS fn function FnhandlerInteger i-integer iitemcountObjects O Object ODIv1Regular expression re RegExp ReemailcheckStrings S String susernameVariable V variant vanything
1.3 Variable DeclarationThe declaration format is: VAR variable name;
var n
Defining arrays
The code is as follows
Copy Code
var a = new Array ("A", "B", "C");Method 1.var mycars=new Array ()mycars[0]= "Saab"mycars[1]= "Volvo"mycars[2]= "BMW"
Method 2.
Define and initialize together:
The code is as follows
Copy Code
var mycars=new Array ("Saab", "Volvo", "BMW")
Or another way of writing:
The
The definition of JS array:
The code is as follows
Copy Code
Method 1.var mycars=new Array ()mycars[0]= "Saab"mycars[1]= "Volvo"mycars[2]= "BMW"Method 2.Define and initialize together:var mycars=new Array ("Saab", "Volvo", "BMW")Or another way of writing:var mycars=["Saab", "Volvo", "BMW"];
2, access to elements of the array
The definition of an array:
Method 1.
Copy Code code as follows:
var mycars=new Array ()
mycars[0]= "Saab"
mycars[1]= "Volvo"
mycars[2]= "BMW"
Method 2.
Define and initialize together:
var mycars=new Array ("Saab", "Volvo", "BMW")
Or another way of writing:
var mycars=["Saab", "Volvo", "BMW"];
JavaScript two-dimensional array
In the Java language, the string class is considered one of the most frequently used classes. Let's briefly summarize the knowledge points of string today.Let's give you two questions:1. The string "I love Java" occupies a few bytes in memory?2. Give the operation result of the following program.1 Public classTest {2 3 Public Static voidMain (string[] args) {4 //TODO auto-generated Method Stub5String S1 = "ABC";6String s2 = "abc";7 8String s3 =NewString ("ABC");9String S4 =
When s1 is created, the string constant pool has one "hello". When s2 is created, the constant pool is no longer created because it is also "hello, s2 points directly to the created constant
So s1 = s2 true
String s3 = new String ("hello ");String s4 = new String ("hello ");
As long as you see the object created by new, it must be in the heap memory. new indicates applying for a new space for storage.
S1 = s3 falseS3 = s4 false
S5 = "he" + "llo ";S6
Len, listen to cap) listen to//t is the type of data that is sliced, Len says Length,cap says capacity{listen to listen: = Listen to make ([]int,5) listen and listen to the//len: Listen to the 5 listen to the CAP: Listen to listen to listening to]int,5,10 listen to listen to listen to hear: = Listen to//len: Listen to the 5 listen to the CAP: listen to 10 listen to listen to listening to hear: = Listen to []int{1,2,3}} Listen to listen to hear {listen listening to arr: = hear [...] int{0,1,2,3,
为文本来处理。1.1.6, semicolon??分号用于分隔 JavaScript 语句。??通常我们在每条可执行的语句结尾添加分号。??使用分号的另一用处是在一行中编写多条语句。1.2, variable 1.2.1, variable use声明(创建) JavaScript 变量var carname;变量赋值 carname="Volvo";例, 标签页需要在script之上 1.2.2, variable naming rules1. Camel Marking method?? The first letter is lowercase, and the next letter begins with an uppercase character. For example:?? ?? var mytestvalue = 0, Mysecondvalue = "HI";2. Pascal Marking method?? The first letter is capitali
!Compare for And whileIf you have read the previous chapter about the for loop, you will find that the while loop is much like the for loop.For statement instanceThe loop in this example uses a for loop to display all the values in the cars array:cars=["BMW", "Volvo", "Saab", "Ford";var i=0;for (; Cars[i];){document.write (Cars[i] + "i++;}While statement instanceThe loop in this example uses a while loop to display all the values in the cars array:car
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.