2014-07-13 01:04:16 +02:00
|
|
|
|
//// [instanceofOperator.ts]
|
|
|
|
|
// Spec:
|
|
|
|
|
// The instanceof operator requires the left operand to be of type Any or an object type, and the right
|
|
|
|
|
// operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the
|
|
|
|
|
// Boolean primitive type.
|
|
|
|
|
|
2014-10-15 00:18:44 +02:00
|
|
|
|
module test {
|
|
|
|
|
class Object { }
|
|
|
|
|
var obj: Object;
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-15 00:18:44 +02:00
|
|
|
|
4 instanceof null;
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
2014-10-15 00:18:44 +02:00
|
|
|
|
// Error and should be error
|
|
|
|
|
obj instanceof 4;
|
|
|
|
|
Object instanceof obj;
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
2014-10-15 00:18:44 +02:00
|
|
|
|
// Error on left hand side
|
|
|
|
|
null instanceof null;
|
|
|
|
|
obj instanceof Object;
|
|
|
|
|
undefined instanceof undefined;
|
|
|
|
|
}
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//// [instanceofOperator.js]
|
2014-08-14 15:42:18 +02:00
|
|
|
|
// Spec:
|
|
|
|
|
// The instanceof operator requires the left operand to be of type Any or an object type, and the right
|
|
|
|
|
// operand to be of type Any or a subtype of the ‘Function’ interface type. The result is always of the
|
|
|
|
|
// Boolean primitive type.
|
2014-10-15 00:18:44 +02:00
|
|
|
|
var test;
|
|
|
|
|
(function (test) {
|
|
|
|
|
var Object = (function () {
|
|
|
|
|
function Object() {
|
|
|
|
|
}
|
|
|
|
|
return Object;
|
|
|
|
|
})();
|
|
|
|
|
var obj;
|
|
|
|
|
4 instanceof null;
|
|
|
|
|
// Error and should be error
|
|
|
|
|
obj instanceof 4;
|
|
|
|
|
Object instanceof obj;
|
|
|
|
|
// Error on left hand side
|
|
|
|
|
null instanceof null;
|
|
|
|
|
obj instanceof Object;
|
|
|
|
|
undefined instanceof undefined;
|
|
|
|
|
})(test || (test = {}));
|