You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
727 B

/*
* CheckObjectCoercible() (E5 Section 9.10).
*
* This primitive cannot be directly tested. It is referenced in the
* specification almost exclusively for String.prototype functions, like
* charAt().
*
* We use String.prototype.charAt() for indirect testing.
*/
function indirectCheckObjectCoercible(x) {
String.prototype.charAt.call(x, 0);
}
/*===
TypeError
TypeError
no error
no error
no error
no error
no error
no error
no error
===*/
var values = [ undefined, null, true, false, 123.0, "foo", {}, [], function () {} ];
var i;
for (i = 0; i < values.length; i++) {
try {
indirectCheckObjectCoercible(values[i]);
print('no error');
} catch (e) {
print(e.name);
}
}