How to declare array of specific type in javascript -
is possible in java script explicitly declare array array of int(or other type)?
something var arr: array(int)
nice...
var stronglytypedarray=function(){ this.values=[]; this.push=function(value){ if(value===0||parseint(value)>0) this.values.push(value); else return;//throw exception }; this.get=function(index){ return this.values[index] } }
edits: use follows
var numbers=new stronglytypedarray(); numbers.push(0); numbers.push(2); numbers.push(4); numbers.push(6); numbers.push(8); alert(numbers.get(3)); //alerts 6
Comments
Post a Comment