var arr = red green blue pink blue;consolelogarrindexOfblue;
The output of the code will be:
2
This is because the indexOf() method returns the index of the first occurrence of the specified element in the array. In this case, 'blue' appears twice in the array, but the method returns the index of the first occurrence, which is at index 2.
原文地址: https://www.cveoy.top/t/topic/bkHS 著作权归作者所有。请勿转载和采集!