I was trying to figure this out for some common code that we are putting together so I ran the following test:
function TestReferences() {
var contextA = SP.ClientContext.get_current();
var contextB = SP.ClientContext.get_current();
contextA.test = 5;
alert(contextB.test); //Displays 5 alert(contextA == contextB); //Results in True
alert(contextA === contextB); //Results in True
}
The result was that each call to SP.ClientContext.get_current() returns the same instance each time, which is what I was hoping based on the name of the function. This is also true for the get_web() call off the client context object. If you need to return a different context then you can still spin up your own, but if you want to reuse the same context between pieces of code then SP.ClientContext.get_current() allows you to do that without having create your own variable to share out the instance.
Load comments