Created
April 17, 2018 20:48
-
-
Save antoinefortin/35cc8b32ed1dac8a0d3b2d54aada8c75 to your computer and use it in GitHub Desktop.
[Looping Through each item of an array Javascript]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loopArrayLabelAndValue(obj) { | |
for (var prop in obj) { | |
if (obj.hasOwnProperty(prop)) { | |
// or if (Object.prototype.hasOwnProperty.call(obj,prop)) for safety... | |
alert("prop: " + prop + " value: " + obj[prop]) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment