Facebook – https://www.facebook.com/TheNewBoston-464114846956315/
GitHub – https://github.com/buckyroberts
Google+ – https://plus.google.com/+BuckyRoberts
LinkedIn – https://www.linkedin.com/in/buckyroberts
reddit – https://www.reddit.com/r/thenewboston/
Support – https://www.patreon.com/thenewboston
thenewboston – https://thenewboston.com/
Twitter – https://twitter.com/bucky_roberts
Original source
41 responses to “Beginner JavaScript Tutorial – 35 – Associative Arrays”
I would rather be using an object instead, in case i wanted to access by the string ๐
Isn't! it is same as hash function?
Danke Bucky
document.write("buckys favorite food is " + bucky.food);
this works as well ๐
You meant blue waffle? lol
Thanks a lot ๐
NAhhhh man this is wrong. Arrays only store positive integer indexes; Your making a object, use that.
I would call that a map ๐ having a pair of key and value
Thank you for the tutorial.
GOD bless you, Bucky.
According to :http://www.w3schools.com/js/js_arrays.asp
The Difference Between Arrays and Objects?
In JavaScript, arrays use numbered indexes. ย
In JavaScript, objects use named indexes.
I think this tutorial is a bit misleading. In this documentation
http://www.w3schools.com/js/js_arrays.asp
it says that there is no associative array in js. If you use named indexes, the array will be converted to objects.
how come when you try to do document.write(bucky); .. nothing happens.. the values blue and hot pockets are not being stored inside the array ? .. it seems like the ["color"] and ["food"] act as properties .. similar to when you do bucky.length .. its just bucky["color"] instead .. ?
white isn't a colour >_>
This would be good for handling user's data form a database
Thank you man! It helps me a lot!!
Is this common used when you are having like a database full of users and user's information?
why </br> doesnt work in this example?
<script language = "javascript">
var laith = new Array();
laith["dudee"]= "omar";
laith["boring"]="qutaiba";
document.write("laith's dudee is "+laith["dudee"] +<br/>+"laith boring friend is "+laith["boring"]);
</script>
Man, what the hell "anywayS" is? I knew it as "anyway" ๐ย
Good five bro, go on ๐
Man we really need hot pockets in Denmark :[
viewing as 44,000th…
Why do people say that java and javascrip are two different things?
well ofcourse javascript is used for web designing and java is for applications/softwares. but syntaxes are "pretty much" the same! :/
Bucky is a cool fellow.
me too
I thought he's favourite food is Tuna…..
what are these hot pockets !?
Did kelsey love your blue mouth?
I have been wating for this video a long time.
hey man upload intermediate and advanced javascript tutorials
I Downloader all Your Videos
Thanks for the tutorial !
Yes, indices work just fine.
I think PHP first
5 more vids.. Then finally.. HTML5 ๐
5 more tutorials until I can…. Watch the intermediate vids!
Array IS an object. It DOES have properties. Do you even know Javascript? On top of that it might help to realize almost everything is an object with a prototype you can attach methods and properties to.
You're only attaching new properties to the Array object, and then assigning values. You're not actually utilizing an array in anyway. You could have done this with ANY object. This literally accomplishes nothing.
There are no associative arrays in Javascript, and almost everything is an object.
So I'm guessing that means you could still reference them with the index number… ?
1 type of array, (indexed, ex: foo[0], foo[1], etc). This video is a little misleading. ๐
1 dislike, who the fuck would do that
There are no associative arrays in JavaScript. ๐ All you're doing is instantiating the Array object and then attaching properties to it.
0 dislikes, hecka ya Bucky, that's how it should be ๐