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
@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
AreaOfRectangle
function computeArea(width, height) {
// your code here
return width*height
}
/* From here down, you are not expected to
understand.... for now :)
Traffic Lights
https://jsbin.com/getecu/edit?js,console,output
Errors
https://jsbin.com/saqeca/edit?js,console,output
<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>
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
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
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/ratobix/edit?js,output
drill 2
https://jsbin.com/razodol/edit?js,console,output
drill 3
https://jsbin.com/wuxinit/edit?html,js,console,output
@yasirjanjua
yasirjanjua / events-delivery-endpoint.xml
Created August 12, 2020 12:20
Sample WSO2 Endpoint for a MockService
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="events-delivery-endpoint" xmlns="http://ws.apache.org/ns/synapse">
<http method="post" uri-template="http://localhost:8290/services/EventsConsumerService">
<suspendOnFailure>
<errorCodes>-1</errorCodes>
<initialDuration>0</initialDuration>
<progressionFactor>1.0</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
@yasirjanjua
yasirjanjua / events-delivery-service.xml
Created August 12, 2020 12:24
Sample WSO2 proxy-service for storing events to WSO2 store
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="events-delivery-service" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<log level="custom">
<property expression="//Event" name="Event Received"/>
</log>
<store messageStore="events-store"/>