简体   繁体   English

在一个函数中将非全局变量用于单独的函数(Javascript)

[英]Using a non-global variable in one function for a separate function (Javascript)

I've been trying to use the "rx" and "ry" variables in a seperate function ( http://i.stack.imgur.com/tV8ln.png ) And I cant figure out how to do it, I've tried using rx and ry as parameters for calling the function and even the function itself but It hasn't worked. 我一直在尝试在单独的函数中使用“ rx”和“ ry”变量( http://i.stack.imgur.com/tV8ln.png )而且我不知道该怎么做,尝试使用rx和ry作为参数来调用函数,甚至调用函数本身,但是它没有用。 And I am unable to make it a global variable because it requires many others leading up to it. 而且我无法使其成为全局变量,因为它需要很多其他变量来实现。 Ive looked up how to do it and nothing has worked, so I thought I would ask here because there are many experienced coders on here that probably know how and I'm just a noob, 我已经看了怎么做,却没有任何效果,所以我想在这里问一下,因为这里有很多经验丰富的编码员,他们可能知道怎么做,而我只是个菜鸟,

Here's the raw paste, If anyone can help me solve this It would be greatly appreciated :) http://pastebin.com/UWY8QKbW 这是原始浆糊,如果有人可以帮助我解决这个问题,将不胜感激:) http://pastebin.com/UWY8QKbW

Pass them in: 将它们传递给:

PlayerCell.prototype.borderCheck = function(rx, ry) {

And call appropriately: 并适当地致电:

this.borderCheck(rx, ry);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM