1 Déterminez s'il s'agit d'un type de tableau
2 Déterminez s'il s'agit d'un type de chaîne
3 Déterminez s'il s'agit d'un type numérique
4 Déterminez s'il s'agit du type de date
5 Déterminez s'il s'agit d'une fonction
6 Déterminez s'il s'agit d'un objet
1 Déterminez s'il s'agit d'un type de tableau
Copier le code du code comme suit:
<script type = "text / javascript">
// <! [Cdata [cdata [
var a = [0];
Document.Write (isArray (a), '<br/>');
fonction isArray (obj) {
Return (typeof obj == 'objet') && obj.constructor == array;
}
//]]>
</cript>
2 Déterminez s'il s'agit d'un type de chaîne
Copier le code du code comme suit:
<script type = "text / javascript">
// <! [Cdata [cdata [
document.write (isstring ('test'), '<br/>');
Document.Write (Isstring (10), '<br/>');
fonction isstring (str) {
Return (typeof str == 'string') && str.constructor == String;
}
//]]>
</cript>
3 Déterminez s'il s'agit d'un type numérique
Copier le code du code comme suit:
<script type = "text / javascript">
// <! [Cdata [cdata [
document.write (isNumber ('test'), '<br/>');
Document.Write (isNumber (10), '<br/>');
fonction isNumber (obj) {
Return (typeof obj == 'nombre') && obj.constructor == numéro;
}
//]]>
</cript>
4 Déterminez s'il s'agit du type de date
Copier le code du code comme suit:
<script type = "text / javascript">
// <! [Cdata [cdata [
document.write (isDate (new Date ()), '<br/>');
Document.Write (isdate (10), '<br/>');
Fonction isdate (obj) {
Return (typeof obj == 'objet') && obj.constructor == Date;
}
//]]>
</cript>
5 Déterminez s'il s'agit d'une fonction
Copier le code du code comme suit:
<script type = "text / javascript">
// <! [Cdata [cdata [
document.write (isFunction (fonction test () {}), '<br/>');
document.write (isfunction (10), '<br/>');
Fonction isfunction (obj) {
Return (typeof obj == 'function') && obj.constructor == function;
}
//]]>
</cript>
6 Déterminez s'il s'agit d'un objet
Copier le code du code comme suit:
<script type = "text / javascript">
// <! [Cdata [cdata [
document.write (isObject (new object ()), '<br/>');
document.write (isObject (10), '<br/>');
fonction isObject (obj) {
Return (typeof obj == 'objet') && obj.constructor == objet;
}
//]]>
</cript>