Skip to content

Tag: javascript

URL of open(…) relative or absolute

I don’t quite understand the functioning of the url parameter of XMLHttpRequest open(method, url, async). Let’s say I have a web server like that: page.html sends an asynchronous request to controller.php. As we can only send requests to our own web server, I assume that we don’t have to rew…

Maximum Subarray (Kadane’s algorithm approach)

https://leetcode.com/problems/maximum-subarray/description/ Input test case: [-2,1,-3,4,-1,2,1,-5,4] [-2, -1] [-2, 1] [1] [1, 2] I wanted to pass this case Input: [-2, -1] so that I modified var currentMax = 0; and var max = 0; to current code. Apparently, Kadane’s algorithm is needed to include at leas…

vue js cant understand keep alive

I’m doing tests with this code: https://jsfiddle.net/b2qj69o1/25/ And the js part I did the alert() test to see whether vue will re-render the component. I see that with or without wraping <component> with <keep-alive>, the alert() if called only the first time I enter the Home tab. So I hav…

js get list of own static properties

I have a class with static properties and I want to get a list of all property values: Now I want to get: [‘all time’, ‘month’, ‘week’, ‘day’] Answer What’s your use case here? If you’re looking for a way to have some properties that you can iterate …

Multiply (a)(b) function possible?

I have an oddball of a question from a code quiz. They expect me to write a function that multiplies (a) and (b) but instead of writing it like: They expect me to do the math with: Is it possible ? Answer Make a function that returns another function.