Function methods in prototype become undefined

I have planned to get a rid of jQuery, just to learn more plain javascript to build my own libraries. I have created function __ similar to jQuery’s $. First prototype method I choose to be _addClass which actually add a class to DOM element(s); Html code is simple: (() => { function __(arg) {… Read More Function methods in prototype become undefined

Prototypes on Custom Elements

Suppose I have a custom HTML element tag <custom-table> with an attribute tableVal="10". I would like to easily fetch the tableVal without using .getAttribute() (since I’m creating a public API that is easy-to-use). Here’s what I’m trying to do: var customElement = document.querySelector(‘custom-table’); console.log(customElement.val) Output: undefined Expected Output: 10 This is my current try: Object.setPrototypeOf(customElements.prototype,… Read More Prototypes on Custom Elements

Why do inherited properties print later than other properties?

let animal = { eats: true }; let rabbit = { __proto__: animal, // (*) jumps: true, // (**) }; console.log(Object.keys(rabbit)); // [jumps] for(let prop in rabbit) console.log(prop); // jumps, eats Why do inherited properties in the (*) line print later than property in the (**) line when we print properties in the for..in loop,… Read More Why do inherited properties print later than other properties?

How to call the Win32 GetCurrentDirectory function from C#?

The prototype of GetCurrentDirectory DWORD GetCurrentDirectory( [in] DWORD nBufferLength, [out] LPTSTR lpBuffer ); DWORD is unsigned long, LPTSTR is a pointer to wchar buffer in Unicode environment. It can be called from C++ #define MAX_BUFFER_LENGTH 256 int main() { TCHAR buffer[MAX_BUFFER_LENGTH]; GetCurrentDirectory(MAX_BUFFER_LENGTH, buffer); return 0; } I tried to encapsulate this win32 function in C#,… Read More How to call the Win32 GetCurrentDirectory function from C#?

Unable to retrieve multiple values from database

The following data exists in the database: [ { "_id": { "$oid": "628c787de53612aad30021ab" }, "ticker": "EURUSD", "dtyyyymmdd": "20030505", "time": "030000", "open": "1.12161", "high": "1.12209", "low": "1.12161", "close": "1.12209", "vol": "561", "id": 1 }, { "_id": { "$oid": "628c787de53612aad30021ac" }, "ticker": "EURUSD", "dtyyyymmdd": "20030505", "time": "030100", "open": "1.12206", "high": "1.1225", "low": "1.12206", "close": "1.1225", "vol": "1223",… Read More Unable to retrieve multiple values from database

How can i get a index value of a div just clicking on it?

I’m trying to change the class of an specific div that i click, using this: let divs = document.querySelectorAll(‘.x’); function idk(){ Array.prototype.forEach.call(divs, function(element) { element.classList.add(‘y’); Array.prototype.forEach.call(divs, function(element) { element.classList.remove(‘x’); }); }); } .y{ transition: 0.5s; transform: rotateY(180deg); } <div id=”d1″> <div id=”c1″ class=”x” onclick=”idk()”>a</div> <div id=”c2″ class=”x” onclick=”idk()”>b</div> <div id=”c3″ class=”x” onclick=”idk()”>c</div> </div> This code… Read More How can i get a index value of a div just clicking on it?