在javascript中将var转换为int作为java [英] Convert var to int as java in javascript
本文介绍了在javascript中将var转换为int作为java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在javascript中我可以将值转换或传递给var a =<<%b%> ;;
但我无法转换<%b%> = var获取错误
我的尝试:
in javascript i can convert or pass values to var a= <<%b%>;
but i cant able to convert <%b%>=var its getting error
What I have tried:
for(var a=1;a<=intTextBox ;a++)
{
var doct_id = parseFloat(array[a-1]);
<%int b;%>
<%b%> = doct_id;
}
推荐答案
没有这样的事情。这个问题毫无意义,因为var
是关键字,而不是数据类型,并且没有int这样的东西。没有什么可以转换的。也许您需要了解JavaScript类型系统,它基于一种松散型范例。请特别注意:
JavaScript数据类型和数据结构 - JavaScript ,
typeof - JavaScript 。
无论如何,假设您在代码中使用的变量按预期初始化,它会为您提供正确的代码;例如,它可能是
There is no such thing. The question makes no sense, becausevar
is a key word, not a data type, and there is no such thing as "int". There is nothing to convert. Perhaps you need to understand JavaScript type system, which is based on a kind of "loose-type paradigm". Please see, in particular:
JavaScript data types and data structures — JavaScript,
typeof — JavaScript.
Anyway, assuming the variables you use in your code are initialized as expected, it gives you correct code; for example, it could be
var array = [1.1, 2.2, 3.3];
var intTextBox = array.length;
// intTextBox is redundant,
// you could use array.length in the loop:
for (var a = 1; a <= intTextBox; a++) {
var doct_id = parseFloat(array[a - 1]);
doSomething(doct_id);
}
换句话说,我没有看到你的代码片段有任何问题;你只是没有解释它的背景。
这篇关于在javascript中将var转换为int作为java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文