pro - is a name of current key, obj[pro] - it's value :)

On 1 дек, 13:36, Rahul <[email protected]> wrote:
> hi everyone,
> i am new to javascript, and learning day by day.
> this is my code,
>
> var obj_1 = {
>                 prop01 : "PROP-01",
>
>                 prop02 : "PROP-02",
>
>                 prop03 : "PROP-03",
>
>                 prop04 : function(){
>                         alert("PROP-04");
>                 },
>
>                 prop05 : "PROP-05",
>
>                 prop06 : function(){
>                         alert("PROP-06");
>                 }
>         }
>
>         for(pro in obj_1){
>                 if(typeof pro === 'function'){
>                         alert(" --> "+pro+" is a function ");
>                 }else{
>                         alert(" --> "+pro+" is a property ");
>                 }
>         }
>
> what i am expecting is for property "prop04" & "prop06" the alert
> message will be "pro04 is a function" and  "pro04 is a function"
> respectively,
>
> but here for all the properties the second alert is printed,
>
> so my question is whether type 'method' and 'function' are different

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to