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"function":o.pop?"array":o instanceof Boolean?"boolean":+o==o?"number":o.charAt?"string":o.toString()=="[object Object]"?"object":"undefined"}


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.