JavaScript Ducktyping


/ Published in: JavaScript
Save to your folder(s)

Guess the type of any object applying ducktyping


Copy this code and paste it in your HTML
  1. function type(o){return o.call?"function":o.pop?"array":o instanceof Boolean?"boolean":+o==o?"number":o.charAt?"string":o.toString()=="[object Object]"?"object":"undefined"}

URL: http://www.twitter.com/pablo_PXL

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.