How do I use arc4random in JavaScript? I tried to use var randomNumber = (arc4random() % 83) + 1; but I got UncaughtReferenceError: arc4random is not defined. I am not sure which libs to include to use arc4random.

有帮助吗?

解决方案

I do not believe it possible, given all research points to the fact that arc4random is not a js function, but one built in to objective-c, or ios. I'm beginning to believe you did little research into the matter. Even the tag wiki entry on SO says as much.

其他提示

arc4random() is not defined in JavaScaript. To generate random numbers in JavaScript you can use Math.random(). But I think you can easy emulate arc4random() as:

function arc4random(){
  return Math.random()*4294967296;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top