In example, I need to determine the position of 'wink' in the smiley array in order to determine which value to select in the smiley_bb array.
Code: Select all
var smiley = ['happy', 'wink'];
var smiley_bb = [':)', ';)'];Thoughts please?
Moderator: General Moderators
Code: Select all
var smiley = ['happy', 'wink'];
var smiley_bb = [':)', ';)'];Code: Select all
var smiley = { 'happy' : ':)', 'wink' : ';)' };
Code: Select all
var answer = the_array.indexOf('the_value');Unfortunately, this wont work in IEvar answer = the_array.indexOf('the_value');
Why? It's locally stored data, so it could be implemented with "static-like" JS object, without playing with JSON coding.Chris Corbyn wrote:JSON++
I should have said object-literal. I just meant don't use an array when you want to map named keys to valuesVladSun wrote:Why? It's locally stored data, so it could be implemented with "static-like" JS object, without playing with JSON coding.Chris Corbyn wrote:JSON++