two questions

S

sleepinglord

1.How to get the class of an object. or how to judge an object has the
same type of another.

for example. Array. How to judge an object is an Array object or not?

typeof() will return "object",
..isPrototypeOf() seems always return false or error.
for(a in Array.prototype) tell me, there's nothing in Array.prototype.

Then how to?

2.How to get the elements of an Array inside in a local function?

for example, I wanna add a toStrangeString () function to Array. The
code looks like this.
toStrangeString: function(){
var getELes = ?; //how to?
//compose the string and return
}
 
R

RobG

1.How to get the class of an object. or how to judge an object has the
same type of another.

for example. Array. How to judge an object is an Array object or not?

typeof() will return "object",
.isPrototypeOf() seems always return false or error.
for(a in Array.prototype) tell me, there's nothing in Array.prototype.

Then how to?

var x = [];
alert(
'x.constuctor: ' + x.constructor + '\n' +
'x instanceof Array?: ' + (x instanceof Array)
);


No time to answer 2. right now...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top