Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

display object in array

//Example: 1
var arr =[1,2,4,5,6];
$.each(arr,function(index,obj)
{
    //We can access the object using obj or this
    alert("index:"+index + " , value: "+obj +" , value:"+this);
     
});
 
//Example: 2 (JSON Array)
var arr2 =[{
                name:"Ravi",
                age:33,
                loc:"India",
            },
            {
                name:"Haya",
                age:4,
                loc:"United States"
            },
            {
                name:"Geek",
                age:4,
                loc:"Singapore"
            }];
$.each(arr2,function(index,obj)
{
    alert("Name: "+obj.name+"
"+"Age:"+obj.age+"
"+"Location: "+obj.loc+"
");
});
Source by hayageek.com #
 
PREVIOUS NEXT
Tagged: #display #object #array
ADD COMMENT
Topic
Name
4+6 =