var arr = [1,2,3];
var obj_arr = {'one':1,'color':'red','five':5};
var fun = function (){ console.log('test ...'); }
function abc(){ console.log('test ...'); }
var obj_fun = new abc();
var obj = {
key:1256,
abc : function (){ console.log('test ...'); }
}
(arr instanceof Array); // true
(arr instanceof Object); // true
(obj_arr instanceof Array); // false
(obj_arr instanceof Object); // true
(obj_fun instanceof Object); // true
(obj_fun instanceof Array); // false
'abc' instanceof String // false
true instanceof Boolean // false
3 instanceof Number // false
parseInt(25) instanceof Number // false
new Number(3) instanceof Number // true
3..constructor === Number // true
'abc'.constructor === String // true
true.constructor === Boolean // true
document.constructor === HTMLDocument // true
window.constructor === Window // true
document.getElementById.constructor === Function // true
Math.constructor === Math // false
Math.constructor === Object // true
typeof 3; // number
typeof 'abc'; // string
typeof true; // boolean
typeof arr; // object
typeof obj_arr; // object
typeof obj_fun; // object
typeof document; // object
typeof window; // object
typeof document; // object
typeof Math;// object
Object.prototype.toString.call('string'); // [object String]
Object.prototype.toString.call(125); // [object Number]
Object.prototype.toString.call(true); // [object Boolean]
Object.prototype.toString.call(window); // [object Window]
Object.prototype.toString.call(document); // [object HTMLDocument]
Object.prototype.toString.call(document.getElementById); // [object Function]
Object.prototype.toString.call(Math); // [object Math]
Object.prototype.toString.call(arr); // [object Array]
Object.prototype.toString.call(obj_arr); // [object Object]
Object.prototype.toString.call(fun); // [object Function]
Object.prototype.toString.call(obj_fun); // [object Object]
Object.prototype.toString.call(obj); // [object Object]
Object.prototype.toString.call(null); // [object Null]
Object.prototype.toString.call(undefined); // [object Undefined]
var toString = Object.prototype.toString;
toString.call(new Date); // [object Date]
toString.call(new String); // [object String]
function ESObjType(obj){
/*
* Get object type by string
* @param (any object value) obj - object value
*
* @return (string) object type
*
* source : http://codrate.com/articles/dynamically-generate-slug-in-php
*/
return Object.prototype.toString.call(obj).slice(8, -1);
}
ESObjType('string'); // String
ESObjType(125); // Number
ESObjType(true); // Boolean
ESObjType(null); // Null
ESObjType(undefined); // Undefined
ESObjType(document); // HTMLDocument
ESObjType(obj_arr); // Object
ESObjType(obj_arr); // Object
ESObjType(fun); // Function
Who get fresh code scripts from codrate!
Will send your codrate site configuration email in your mail account.
codrate.com is a standard, fast cross browsing and highly versatile site. It is useful for many large number of Program Development Industries. So you can get support form Codrators , who are the codrate's joiners around world to help your program developments, You can answer other codrator's questions. Communicate with them. Share your knowledge with them. Do you have an interest in programming, So publish your articles about programming. It will help to maintain your professional co-profile. Actually codrate.com is not such as a regular web site. It will be gave new experience, best narrow cross-browser view, reduce processing time to receive browsing request, it's mean do not wasting your time to browsing codrate's web pages because it has been upgrade always modern coding ways. So, what do you waiting for ?. Try your own.