Skip to content

Instantly share code, notes, and snippets.

View yasirjanjua's full-sized avatar
🎯
Focusing

Yasir Janjua yasirjanjua

🎯
Focusing
  • Lahore,Pakistan
View GitHub Profile
drill 1
href="https://jsbin.com/jehiyes/embed?js,console"
drill 2
https://jsbin.com/rawebir/edit?js,console
drill 3
https://jsbin.com/sifawow/edit?js,console
drill 4
https://jsbin.com/dudinex/edit?js,console
drill 5
https://jsbin.com/jegixi/edit?js,console
drill 1
https://jsbin.com/fenonuq/edit?js,console
drill 2
https://jsbin.com/yejarip/edit?js,console
drill 3
https://jsbin.com/sunuboz/edit?js,console
drill 4
https://jsbin.com/jijarix/edit?js,console
What is scope? Your explanation should include the idea of global vs. local scope.
JavaScript has two scopes: global and local. A variable that is declared outside a function definition is a global variable, and its value is accessible and modifiable throughout your program. A variable that is declared inside a function definition is local
Why are global variables avoided?
Global variables are accessible through out the program and their value can be manipulated unwantedly which causes error. That is why global variables are avoided.
Explain JavaScript's strict mode
JavaScript strict mode changes silent mistakes to throw erroes.It doesn't allow any variable to get initialize without proper delaration.
What are side effects, and what is a pure function?
A pure function doesn't depend on and doesn't modify the states of variables out of its scope. Concretely, that means a pure function always returns the same result given same parameters.
Explain variable hoisting in JavaScript.
The behaviour of js interpreter
<h1>Drill 1<h1/>
<a class="jsbin-embed" href="https://jsbin.com/woyefo/embed?js,console">JS Bin on jsbin.com</a><script src="https://static.jsbin.com/js/embed.min.js?4.0.2"></script>
<h1>Drill 2<h1/>
<a class="jsbin-embed" href="https://jsbin.com/lobolob/embed?js,console">JS Bin on jsbin.com</a><script src="https://static.jsbin.com/js/embed.min.js?4.0.2"></script>
<h1>Drill 3<h1/>
<a class="jsbin-embed" href="https://jsbin.com/nigeke/1/embed?js,console">JS Bin on jsbin.com</a><script src="https://static.jsbin.com/js/embed.min.js?4.0.2"></script>
<h1>Drill 4<h1/>
<a class="jsbin-embed" href="https://jsbin.com/qelazu/5/embed?js,console">JS Bin on jsbin.com</a><script src="https://static.jsbin.com/js/embed.min.js?4.0.2"></script>
<h1>Find<h1/>
<a class="jsbin-embed" href="https://jsbin.com/wiwijac/1/embed?js,output">JS Bin on jsbin.com</a><script src="https://static.jsbin.com/js/embed.min.js?4.0.2"></script>
Traffic Lights
https://jsbin.com/getecu/edit?js,console,output
Errors
https://jsbin.com/saqeca/edit?js,console,output
AreaOfRectangle
function computeArea(width, height) {
// your code here
return width*height
}
/* From here down, you are not expected to
understand.... for now :)
@yasirjanjua
yasirjanjua / JS Drills.txt
Created May 27, 2017 07:55
Thinkful Js Drills
WisePersonGenerator
function wisePerson(wiseType, whatToSay) {
// your code here
var str = 'A wise ' + wiseType + ' once said: "' +
whatToSay + '".';
return str;
}
/* From here down, you are not expected to