longtone Posted January 19, 2011 Share Posted January 19, 2011 aaa = 'boo a'; bbb = new Array(); bbb['av'] == 'boo b'; alert(aaa); alert(bbb['av']); displays: alert('boo a') then alert('undefined') I know this is something really basic, but why is it undefined when I've declared the array and given the element a value? see it in action: http://www.phpplaypen.co.uk/jso.php Link to comment https://forums.phpfreaks.com/topic/225024-why-is-array-element-undefined-when-i-have-defined-it/ Share on other sites More sharing options...
Maq Posted January 19, 2011 Share Posted January 19, 2011 You're using an comparison (==) rather than assignment (=). Link to comment https://forums.phpfreaks.com/topic/225024-why-is-array-element-undefined-when-i-have-defined-it/#findComment-1162237 Share on other sites More sharing options...
longtone Posted January 20, 2011 Author Share Posted January 20, 2011 So you spotted my deliberate mistake... I'll book my brain transplant now Link to comment https://forums.phpfreaks.com/topic/225024-why-is-array-element-undefined-when-i-have-defined-it/#findComment-1162269 Share on other sites More sharing options...
Maq Posted January 20, 2011 Share Posted January 20, 2011 So you spotted my deliberate mistake... I'll book my brain transplant now Eh, those are usually the hardest ones to spot Link to comment https://forums.phpfreaks.com/topic/225024-why-is-array-element-undefined-when-i-have-defined-it/#findComment-1162501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.