In javascript, how user specific operation is identified?

From Internet, I saw code below for handling multi-select check boxes on a list table view:
$(document).ready(function(){
// Activate tooltip
$(‘[data-toggle=“tooltip”]’).tooltip();

// Select/Deselect checkboxes
var checkbox = $('table tbody input[type="checkbox"]');
$("#selectAll").click(function(){
	if(this.checked){
		checkbox.each(function(){
			this.checked = true;                        
		});
	} else{
		checkbox.each(function(){
			this.checked = false;                        
		});
	} 
});
checkbox.click(function(){
	if(!this.checked){
		$("#selectAll").prop("checked", false);
	}
});

});

I’d like to know how the line
var checkbox = $(‘table tbody input[type=“checkbox”]’);
can pick up rows from a specific user’s table? I can only imaging such javascript execution is bundled with request session somehow, and knows all the contexts? If so, does that mean multiple table templates can also use the same ID like #selectAll here without conflict?

This expression:

is a jQuery call to get the list of html elements in the page that satisfies that condition.

See the docs at jQuery() | jQuery API Documentation

Also keep in mind that this executes solely in the browser. The server (and therefore the session) has nothing to do with this.