JavaScript Reference/Javascript Methods/split — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:22, 26 мая 2010
"split()" Example
<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>
"split()" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |String |
+----------------+--------------------------------------------------------------+
"split()" Syntax, Parameters and Note
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.