2011/05/25

Simple Lesson : instanceof in Javascript

I have simple lesson again, when I still write program using javascript.We know that in Javascript, we can assign variable a value like this.

var ProgrammingName = "Javascript";

So, what the meaning instanceof.instanceof mean, is it variable instance of the type or function in Javascript. In another programming languange, we can declare variable with the type like this.

int i;
String name;

Example above different in javascript. We must using "new" keyword for declaration variable like.

var ProgrammingName = new String("Javascript");

What happen if we use instanceof in two type declaration of javascript.

var ProgrammingName = "Javascript";
ProgrammingName instanceof String; // return false

var ProgrammingName = new String("Javascript");
ProgrammingName instanceof String; // return true

Maybe after this we can use instanceof right,correct me if wrong.

No comments:

Post a Comment

Your Comment