question about loops
why we use for loops in javascript instead we can access any thing through built-in methods or if we save something in arrays then it could be easily accessed?why we use loops.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
umair mohsinPosted Feb 20, 2015, 1:40 AM
var arr1=["a","b","c"];
then i can access this array with
document.write(arr1);
or through index no of an array so what is the use of loop
umair mohsinPosted Feb 20, 2015, 1:37 AM
Nanhe SiddiquePosted Feb 19, 2015, 11:14 PM
Jignesh TrivediPosted Feb 19, 2015, 11:09 PM
Hi,
Loop is very important feature of any language. As you suggest we can use through built in methods but In some case built in method is also use loop internally...
Joginder BangerPosted Feb 19, 2015, 3:46 PM
var obj = {
"flammable": "inflammable",
"duh": "no duh"
};
$.each( obj, function( key, value ) {
alert( key + ": " + value );
})