Skip to content

Instantly share code, notes, and snippets.

@ufocoder
Created October 21, 2018 11:58
Show Gist options
  • Select an option

  • Save ufocoder/7df39101a36b1784b853513e15d134c6 to your computer and use it in GitHub Desktop.

Select an option

Save ufocoder/7df39101a36b1784b853513e15d134c6 to your computer and use it in GitHub Desktop.

Revisions

  1. ufocoder created this gist Oct 21, 2018.
    6 changes: 6 additions & 0 deletions type.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    function type(value) {
    var regex = /^\[object (\S+?)\]$/;
    var matches = Object.prototype.toString.call(value).match(regex) || [];

    return (matches[1] || 'undefined').toLowerCase();
    }