Hi there,

I was wondering what the string.split() does. And another question is that I want to loop through the class like Math and find out what functions are defined in it.But, I was not too sure how to that. I tried a couple of things but they unfortunately didn't work.

Thank you..

Recommended Answers

All 2 Replies

Hi
split(separator, limit) - Separates a string into an array of strings based on a separator sent as a parameter to the method. Limit is optional (an integer that specifies the number of splits). Like explode() in PHP.
Example:

<script type="text/javascript"><!--
var str="How are you?";
var ar_str = str.split(" ");
alert(ar_str[1]);           // are
//-->
</script>

I got that before but then I was not too sure how to access the value. that is great. Thank you.

How about If I want to loop through, for example, a Math class to see what methods are available in it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.