JS – Key, Value 가져오기

for (var k in target){
    if (target.hasOwnProperty(k)) {
         alert("Key is " + k + ", value is" + target[k]);
    }
}

hasOwnProperty는 property를 가지고 있는지 확인 할 때 사용한다.

for (var k in target){
    if (typeof target[k] !== 'function') {
         alert("Key is " + k + ", value is" + target[k]);
    }
}

ref

Javascript – how to know the device (android, iOS, etc) on html

i got some article by stack overflow.

you can you use the following thing.

var isMobile = {
    Android: function() {
        return /Android/i.test(navigator.userAgent);
    },
    BlackBerry: function() {
        return /BlackBerry/i.test(navigator.userAgent);
    },
    iOS: function() {
        return /iPhone|iPad|iPod/i.test(navigator.userAgent);
    },
    Windows: function() {
        return /IEMobile/i.test(navigator.userAgent);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
    }
};

how to use this?

just call the function.

// if you want to check it's android or not just do it.
if (isMobile.Android()) {
    // Android
} else {
    // something else
}

thank you for reading.