Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function foo(bar) {
- if (bar > 1) {
- return [1,2,3];
- } else {
- return 1;
- }
- }
- function isArray(obj) {
- return Object.prototype.toString.call(obj) === '[object Array]';
- }
- if (my_value && typeof my_value === 'object' && typeof my_value.length === 'number' &&
- !(my_value.propertyIsEnumerable('length')) { // my_value is truly an array! }
- function isarray(my_value) {
- if (my_value && typeof my_value === 'object' && typeof my_value.length === 'number' &&
- !(my_value.propertyIsEnumerable('length'))
- { return true; }
- else { return false; }
- }
- if(foo(1) instanceof Array)
- // You have an Array
- else
- // You don't
- function is_array_compliant(obj){
- return obj && typeof obj.length != 'undefined';
- }
Add Comment
Please, Sign In to add comment