xgqfrms / FEIQA

FEIQA: Front End Interviews Question & Answers
https://feiqa.xgqfrms.xyz
MIT License
7 stars 0 forks source link

web-components #13

Open xgqfrms opened 6 years ago

xgqfrms commented 6 years ago

web-components

https://developers.google.com/web/fundamentals/web-components/

https://developers.google.com/web/fundamentals/web-components/examples/howto-checkbox https://googlechromelabs.github.io/howto-components/howto-checkbox/#demo

https://developers.google.com/web/fundamentals/web-components/examples/howto-tabs https://googlechromelabs.github.io/howto-components/howto-tabs/#demo

https://developers.google.com/web/fundamentals/web-components/examples/howto-tooltip https://googlechromelabs.github.io/howto-components/howto-tooltip/#demo

https://github.com/GoogleChromeLabs/howto-components

xgqfrms commented 6 years ago

Event Type Checker


    // utils
    /**
     * @author xgqfrms 2018.05.28
     * @description show Event Type
     * @param {String} event
     */
    const showEventType = (event) => {
        let stringType = Object.prototype.toString.call(event),
            type = "";
        switch (stringType) {
            case "[object Function]":
                type = "Function";
                break;
            case "[object Object]":
                type = "Object";
                break;
            case "[object Array]":
                type = "Array";
                break;
            case "[object Number]":
                type = "Number";
                break;
            case "[object Boolean]":
                type = "Boolean";
                break;
            case "[object Symbol]":
                type = "Symbol";
                break;
            case "[object String]":
                type = "String";
                break;
            default:
                // "[object Undefined]"
                // type = `${stringType}`;
                type = undefined;
                break;
        }
        return type;
    };
    /**
     * @author xgqfrms 2018.05.28
     * @description show Typeof
     * @param {String} event
     */
    const showTypeof = (event) => {
        let stringType = typeof (event),
            type = "";
        switch (stringType) {
            case "function":
                type = "Function";
                break;
            case "object":
                if (Array.isArray(event)) {
                    type = "Array";
                } else {
                    type = "Object";
                }
                break;
            case "number":
                type = "Number";
                break;
            case "boolean":
                type = "Boolean";
                break;
            case "symbol":
                type = "Symbol";
                break;
            case "string":
                type = "String";
                break;
            default:
                // "undefined"
                // type = `${stringType}`;
                type = undefined;
                break;
        }
        return type;
    };