JSFiddle - React, Tailwind, and code Playground

HTML

<ul>
    <li data-id="1">One</li>
    <li data-id="2">Two</li>
    <li data-id="3">Three</li>
</ul>

JavaScript

function Test() {

	this.value = '';

}

Test.prototype = {

	// Loader
	init: function(options) {
	
		// Set value
		this.value = options.value;
		
		// This outputs fine
		console.log(this.value);
		
		// I'll now create a loop using the JQuery "each" function
		$('li').each(function() {
		
			// This fails because "this" has now been overwritten by JQuery inside this function
			this.format($(this).attr('data-id'), this.value);
		
		});
	
	},
	
	// Format output
	format: function(id, value) {
	
		console.log(id + ' : ' + value);
	
	}
	
};

var first = new Test();
first.init({ "value" : "a" });

var second = new Test();
second.init({ "value" : "b" });