How do you access a variable inside a function without placing the variable inside of the function in Javascript ?
Siberian
13
Junior Poster
Recommended Answers
Jump to Postif you declare variable outside a function (before declare function) then you can access and change it inside eg
var someVariable; function someFunction(){ someVariable = 5; } alert(someVariable); // undefined someFunction(); alert(someVariable); // 5
but if you redeclare variable with same name inside a function then it's …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.