출처 : http://jqfundamentals.com/book/index.html#chapter-1
var myFunction = function() {
    console.log('hello');
};

var myObject = {
    foo : 'bar'
};

var myArray = [ 'a', 'b', 'c' ];

var myString = 'hello';

var myNumber = 3;

typeof myFunction;   // returns 'function'
typeof myObject;     // returns 'object'
typeof myArray;      // returns 'object' -- careful!
typeof myString;     // returns 'string';
typeof myNumber;     // returns 'number'

typeof null;         // returns 'object' -- careful!


if (myArray.push && myArray.slice && myArray.join) {
    // probably an array
    // (this is called "duck typing")
}

if (Object.prototype.toString.call(myArray) === '[object Array]') {
    // Definitely an array!
    // This is widely considered as the most robust way
    // to determine if a specific value is an Array.
}



posted by 뚱2


제가 모바일에서 주로 사용하는 database는 SQLite입니다.
용량이 작으면서도 RDB의 기능을 잘 갖추고 있습니다.
그렇지만 RDBMS로는 모자르죠 ^^;
SQLite에는 typeof라는 함수가 존재합니다.

Function
        typeof(X)
   
Descript
        The typeof(X) function returns a string that indicates the datatype of the expression X: "null", "integer", "real", "text", or "blob". 


참고 ( http://www.sqlite.org/lang_corefunc.html )

이번에 Oracle을 사용하면서 이와 비슷한 함수를 찾았는데
못찾았습니다. 그러던중 오라클에는 COLS 라는 시스템 테이블이 있어서
그 안에 컬럼에 대한 정보를 저장합니다. 이 테이블을 이용하면 사용자 function을 만들면
typeof 비슷하게 만들수 있을것 같습니다.

SELECT DATA_TYPE
  FROM COLS
 WHERE TABLE_NAME = '테이블명'
   AND COLUMN_NAME = '컬럼명'

posted by 뚱2