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:
// Activate tooltip

// Select/Deselect checkboxes
var checkbox = $('table tbody input[type="checkbox"]');
			this.checked = true;                        
	} else{
			this.checked = false;                        
		$("#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.