我的阵列就是这样:
[["1", "apple 1"], ["1", "pear 2"], ["2", "lemon 1"], ["12", "lemon 12"]]
我愿分别以<代码>one”代替1、2和12个阵列指数0和one>、
、2“
和>“twelve”
。
[["one", "apple 1"], ["one", "pear 2"], ["two", "lemon 1"], ["twelve", "lemon 12"]]
我如何这样做?
我的阵列就是这样:
[["1", "apple 1"], ["1", "pear 2"], ["2", "lemon 1"], ["12", "lemon 12"]]
我愿分别以<代码>one”代替1、2和12个阵列指数0和one>、
、2“
和>“twelve”
。
[["one", "apple 1"], ["one", "pear 2"], ["two", "lemon 1"], ["twelve", "lemon 12"]]
我如何这样做?
var arr = [
[ 1 , apple 1 ], [ 2 , pear 2 ], [ 3 , lemon 3 ]
]
var numbers = [ one , two , three ]
arr.forEach(function (el) {
el[0] = numbers[el[0]]
})
arr // [ [ one , apple 1 ], [ two , pear 2 ], [ three , lemon 3 ] ]
射线指数实际上是插图,为什么 编号[2]
( 2
_ a string)将检索第三名成员。
在阵列上,可使用 例如: http://jsfiddle.net <><>Edit>> 我想提一下的是,这一解决办法要求你把阵列起来: 我可以最快的是: But there are a couple of catches here: if write the 添加最后引文。 然而,更可取的解决办法是: 并将相应的数字作为财产名称。
How to get a selected text inside a iframe.
I my page i m having a iframe which is editable true.
So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem,
In Masterpage, the google analytics code were pasted before the end of body tag.
In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph?
The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change?
I have a form where the user can chose an image for upload. I also have a php script which displays that image resized.
I only wonder if it ...
I ve made a little forum and
I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"...
What s the best way ?
Thanx.
for
-loop,但
var obj = [["1", "apple 1"], ["1", "pear 2"], ["2", "lemon 1"], ["12", "lemon 12"]];
for ( i = 0; i < obj.length ; i++ ) {
switch(obj[i][0]) {
case "1" : obj[i][0] = "one"; break;
case "2" : obj[i][0] = "two"; break;
case "12" : obj[i][0] = "twelve"; break;
}
}
var str = [["1", "apple 1"], ["1", "pear 2"], ["2", "lemon 1"], ["12", "lemon 12"]] .replace(/([")12/g, $1twelve ).replace(/([")2/g, $1two ).replace(/([")1/g, $one );
replace(/([")12/g, $1twelve )
after you ve replaced the ones, it won t work. so to get around this, you could do:str = [["1", "apple 1"], ["1", "pear 2"], ["2", "lemon 1"], ["12", "lemon 12"]] .replace(/([")12"/g, $1twelve" ).replace(/([")2"/g, $1two" ).replace(/([")1"/g, $one" );
var replace = { 1 : one , 2 : two , 12 : twelve };