I have a program isOvel.js which has a function isOvel(str)
and I want to use this function isOvel(str)
in an another program translate.js. Am just started with Javascript functional programming, your help will be much appreciated.!! I could not find any duplicates, please post it if any.
Asked
Active
Viewed 50 times
0

chivas_hvn
- 361
- 3
- 10
- 24
-
Unless the scripts are included on the same page (isOvel.js first) and scoped globally, you can't do that as far as I know – Sterling Archer Nov 18 '15 at 19:23
-
is the function declared in global space? – Todd Nov 18 '15 at 19:23
-
That depends how you're running your Javascript (and has nothing to do with functional programming) – SLaks Nov 18 '15 at 19:23
-
@Todd - No, I haven't declared in global space. – chivas_hvn Nov 18 '15 at 19:26
-
@SterlingArcher - I did not understand the part - 'the scripts are included on the same page'. Am trying to test something with javascript, not developing any webpage. – chivas_hvn Nov 18 '15 at 19:30
-
@SLaks I am just running individual javascript programs, mainly to test functionality. – chivas_hvn Nov 18 '15 at 19:38
-
@chivas_hvn: **How**? Node.js? Rhino? HTML? – SLaks Nov 18 '15 at 19:39
-
@SLaks Using **Node.js** – chivas_hvn Nov 18 '15 at 19:42
-
3You're looking for `require()`. See the documentation. – SLaks Nov 18 '15 at 19:44
-
@SLaks - Yes, this is what I was looking for. Thanks!! – chivas_hvn Nov 18 '15 at 19:56
1 Answers
0
Javascript file isn't "program" is "file" you can include several files on your page.
<html>
<head>
<title>My page</title>
<script src="isOvel.js" type="text/javascript"></script>
<script src="translate.js" type="text/javascript"></script>
</head>
<body></body>
</html>

user2226755
- 12,494
- 5
- 50
- 73
-
Am trying to call and test `isOvel()` functionality from another js program, not building any webpage so please let me know how I can call it. – chivas_hvn Nov 18 '15 at 19:34
-
Did you see onload event ? http://stackoverflow.com/questions/20180251/when-to-use-window-onload – user2226755 Nov 18 '15 at 19:36