/    Sign up×
Community /Pin to ProfileBookmark

Sample 1: when i call a1 its ok but when i call a2 its throw error.
if i use sample 2 its ok but i need to like sample 1
how can i call s1 from a2?
——————Sample 1——————————–

function a1()
{
var deg1 = “var d=’variables’;”+
“function s1()”+
“{“+
” var deg2=’deg2′; “+
” alert(deg2);”+
“}”;
eval(deg1);
s1();
}

function a2()
{
s1();
}

————-and sample 1——————————–

————-Sample 2————————————
var deg1 = “function s1()”+
“{“+
” var deg2=’deg2′; “+
” alert(deg2);”+
” “+
“}”;

eval(deg1);

function a1()
{
s1();
}

function a2()
{
s1();
}

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorDec 29.2005 — I don't sense what you intend to do. Anyway eval() is the eye of the devil. Avoid it whenever is possible. And always is possible...
Copy linkTweet thisAlerts:
@silentshipauthorDec 29.2005 — i just want to reach s1 from my other functions. i just simulate here my problem
Copy linkTweet thisAlerts:
@KorDec 29.2005 — simply:

function a1(){

s1();

}
Copy linkTweet thisAlerts:
@KorDec 29.2005 — or

function a1(){

var myVar1 = s1();

}
Copy linkTweet thisAlerts:
@silentshipauthorDec 29.2005 — @kor please read careful my question, i ask "how can i call s1 from a2? in sample 1"
Copy linkTweet thisAlerts:
@KorDec 29.2005 — I give up... I don't understand what your code wants, really....
×

Success!

Help @silentship spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...