I'm working with this code. Now, just for checking, I printed typeof arr and it displayed "object" in the console. Although, I declared arr as an array in the beginning. Has it been converted to an object? Here's the code:
<script>
function getDomainsOfEmails(text) {
var arr=new Array;
var regex= /[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}/g;
var matches= text.match(regex);
for(var i=0; i<matches.length; i++){
arr[i]=matches[i].match(/@[a-z0-9.-]+\.[a-z]{2,4}/);
}
for(j=0; j<arr.length; j++){
console.log(arr[j]);
}
console.log(typeof arr);
}
getDomainsOfEmails("[email protected] is not a mail? Is [email protected] ? No? google.com? [email protected] gmail.com");
</script>
Also, I would like to know if it's an object, what are its properties and values?
Array()) and it's prototype being by default set with many useful Methods. Positive integer properties designate the keys and their values designate the items of an array. There is a length property as well which is automatically gets updated accordingly through the keys getters and setters (i assume). You can take a proper object and by array sub-classing turn it into an array. stackoverflow.com/a/27986285/4543207