JavaScript Reference/Javascript Methods/split — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:22, 26 мая 2010
"split()" Example
<source lang="javascript">
<html> <body> <script language="javascript"> function function1(){
var myString = "Sample String 1 2 3"; var myArray = myString.split(" "); alert(myArray.length);
} </script> <button onclick="function1();">SPLIT</button> </body> </html>
</source>
"split()" is applied to
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | Applied_To |String | +----------------+--------------------------------------------------------------+
</source>
"split()" Syntax, Parameters and Note
<source lang="javascript">
Note: Uses the specified delimiter to split the String into an array of String.
Syntax:
stringName.split(param1, param2) Parameters:
param1 Required; the delimiter to use. param2 Optional; the maximum number of elements to return in the array. </source>