High-intensity exercise (HIT) combined with creatine monohydrate supplementation (CM) confers greater neurocognitive benefits than either alone.

Hypothesis

High-intensity exercise (HIT) combined with creatine monohydrate supplementation (CM) confers greater neurocognitive benefits than either alone.

Rationale

Combining HIT with CM may enhance creatine’s transport to the brain, leading to greater cognitive, antioxidant, and neuroprotective effects. This is due to creatine’s ability to cross the blood-brain barrier (BBB), potentially increased by exercise-induced blood flow, vasodilation within the brain, and hormonal responses that further stimulate brain creatine uptake. Querido

This mechanistic basis may provide a theoretical framework for enhancing the benefits of other nutraceuticals.

Exercise Brain Benefits

Exercise boosts cerebral blood flow through vasodilation, increased circulatory volume, and enhanced neurovascular coupling, directing blood flow to the brain regions actively engaged in the exercise. High-intensity exercise improves cognitive function and brain health by increasing cerebral blood flow, BDNF, IGF-1, and osteocalcin. S.E. Browne

Creatine Brain Benefits

Creatine supplementation has been shown to improve cognitive function and provide neuroprotection in persons with neurocognitive impairment. J.F. Sandkühler

Creatine supplementation increases brain creatine levels. During stress or trauma, such as intense exercise, creatine supplementation improves oxidative DNA injury and normalizes brain and body creatine levels. S. Forbes

A 2023 review study published in Sports Medicine found long-term high-dosage creatine supplementation increases brain creatine stores, improves cognition and memory, especially in older adults or during times of metabolic stress (e.g. sleep deprivation), improves aspects of recovery from traumatic brain injury in children, and has the potential to reduce symptoms of depression and anxiety. D. Candow

Creatine has shown neuroprotection in PD patients with cognitive decline via creatine transporter uptake. In a rodent model, high-dosage creatine was shown to exert anti-inflammatory, antioxidative, and anti-aggregant effects on α-synucleinopathy. Y. Leem H. Chang

A long-term, multicenter, double-blind, parallel-group, placebo-controlled, 1:1 randomized efficacy trial for 10g of creatine in PD patients showed benefit to the Unified Parkinson’s Disease Rating Scale (UPDRS) both at 1 year and at 18 months, but eventually terminated early with no determined harm or benefit. K. Kieburtz

To address the nutritional requirements for the demands of the HIT group, each participant will also consume a post-workout protein shake.

Exercise and Cerebral Blood Flow

Aerobic exercise can increase cerebral blood flow and potentially enhance BBB permeability, at least temporarily. For the given volumetric load and intensity of the HIT exercise protocol, cardiovascular output will be high, around 75% HRmax (possibly higher for untrained PD patients, depending on individual motor efficiency). The cardiovascular intensity alone should be sufficient to significantly increase cerebral blood flow and promote physiological adaptations.

High-intensity strength training (HIT) increases IGF-1 levels more significantly compared to cardiovascular training. IGF-1 enhances creatine uptake in muscles, and creatine supplementation further increases IGF-1 mRNA expression in human skeletal muscle, providing a synergistic benefit that supports improved muscle performance and recovery, indirectly benefiting cognitive function through reduced fatigue and better overall physical health.

Due to its high energy requirements, brain cells are susceptible to Reactive Oxygen and Nitrogen Species (RONS), mitochondrial damage, and energy depletion. Strength training produces less RONS due to its reliance on the TCA cycle, resulting in lower ratio of oxidative stress than the amount of cardio required to achieve same cerebral blood flow and hormonal benefits.

Creatine Supplementation Studies

Research indicates that creatine supplementation can improve cognitive function and has neuroprotective effects. However, the dosage and duration required for optimal cognitive benefits are still under investigation.

Combined Effects

Many studies have examined the combined effects of exercise and creatine on muscle performance and recovery, but research on cognitive outcomes is less extensive. The hypothesis that HIT could enhance cerebral creatine uptake is supported by the rationale of increased blood flow and transporter activity.

Enhanced Recovery

Intense exercise and cognitive activity depletes brain phosphocreatine (Pcr) levels. Creatine supplementation can mitigate this depletion and improve recovery from high-intensity exercise, as well as cognitive function. C. Rae, A.C. Passaquin

Decreased Oxidative Stress

CM supplementation decreases oxidative stress by reducing the immediate demand on oxidative phosphorylation (OXPHOS) and its production of RONS, and by directly scavenging free radicals. H. Arazi

Double Crossover Design Overview

Participants: Individuals with early Parkinson’s disease (PD) and mild MDS-UPDRS impairment, randomly selected into groups:

Sequence 1
  1. HIT + CM
  2. HIT + Placebo
  3. CM Only
  4. Placebo
Sequence 2
  1. HIT + Placebo
  2. CM Only
  3. Placebo only
  4. HIT + CM
Sequence 3
  1. CM Only
  2. Placebo
  3. HIT + CM
  4. HIT + Placebo
Sequence 4
  1. Placebo
  2. HIT + CM
  3. HIT + Placebo
  4. CM Only

Each participant gets all interventions to control for individual differences, reduce the number of participants needed, and ensure every participant receives an active intervention. Each intervention phase is followed by a 4 week washout period and testing, to monitor possible carryover effects.

Duration: 16 weeks is adequate for observing potential cognitive and neuroprotective effects. Exercise Protocol: High-Intensity Training (HIT): Exercises: Olympic lifts and plyometrics. Frequency & Duration: 70 minutes (including warm-up and cool down), six times per week, supervised to ensure safety, form, and protocol adherence.

For transparency, participants must be fully informed about the potential benefits and risks associated with both the active treatment and the possibility of receiving placebo.

CM Supplementation

Dosage: 10 g of CM daily, split into two 5 g doses (pre- and post-workout), during warm-up and cool-down for HIT group.

Approach for Intensity

Initial Assessment

Assess participants’ current fitness levels, physical condition, and any potential limitations. Develop individualized exercise plans based on the baseline fitness evaluation. Strength Assessment: Calculate 10 RM for deadlift, squat, overhead press, bench press, barbell row, and box jump (height in cm).

For box jump assessment tests, calculate vertical jump, then move to a lower height and gradually increase within a safety threshold to the trainee’s comfort level.

For some bodyweight exercises, it is not possible to directly calculate the 10 RM as for weighted exercises. Instead, use the following formula:

max_reps * intensity * target_reps/10

For example, if the client can do 8 pushups and the desired intensity is 80% of 10 RM for 6 reps, do 8 × 0.8 × 6/10 ≈ 4 pushups. Adjust the number of reps as appropriate to roughly match the desired intensity level.

Progressive Intensity

Begin with 50-60% of maximal 10 repetition effort (10 rm), and increase the intensity 5% every 2-4 weeks, with rest between sets below 60s. Target Intensity Range: Aim to reach and maintain an intensity level of 70-85% of maximal effort for most of the intervention period. This range is typically sufficient to increase blood flow and confer cognitive benefits without excessive risk.

Sessions

  • Day 1: HIT + Zone 2 Cardio
  • Day 2: Zone 3 Cardio (40 min ergometer)
  • Day 3: HIT + Active Recovery
  • Day 4: Zone 3 Cardio
  • Day 5: HIT + Zone 2 Cardio
  • Day 6: Zone 3 Cardio
  • Day 7: HIT + Active Recovery

Zone 3 is 30 min of ergometer at 70% HRMax, at the trainee’s convenience.

Zone 2 is 40 min of walking, monitored with a fitness tracker, at the trainee’s convenience.

Active recovery is 10 minutes of walking, monitored with a fitness tracker, followed by a gentle 30 minute group session consisting of a series of instructor-led mobility movements.

Moderate Intensity Exercise (Zone 3) improves increasing cerebral blood flow and cardiovascular health at a reduced injury risk.

Low Intensity Cardio (Zone 2) improves aerobic endurance and promote recovery, ensuring sustained exercise adherence and minimizing injury risk.

Active Recovery promotes recovery, reduces soreness, and promotes relaxation, contributing to program sustainability.

Incorporating moderate or low intensity exercise and active recovery into a high-intensity training (HIT) routine for individuals, especially those with early Parkinson’s disease (PD), can help mitigate the risk of burnout, overtraining, and CNS overstimulation while still promoting various physiological and cognitive benefits. Here’s a proposed routine that balances HIT with cardio and recovery:

Each 70 minute HIT session begins with a 20 minute warm up, followed by 30 minutes of work, and ends with a 20 minute cool down. Warm Up: 15 minutes of working exercises performed at 40–50% of 10 RM for 10 sets of 3-5 and 10 minutes of mobility and light stretching to avoid injury and improve recovery (hang stretch, scapular pushup, cat/cow, walking, box squat, half kneel hip flexor stretch, etc.). Cool down: 10 minutes of low intensity cardiovascular exercise (fast walking) and 10 minutes of stretching.

HIT Progressive Intensity Exercise Protocol

4 times per week, 30 minutes of working sets, 60 – 75s rest between sets for a total of 15 sets.

Weeks 1-4:
Moderate intensity (50-60% of 10 RM) Volume: 15 sets of 10 repetitions
Weeks 5-8
Increase to moderate-high intensity (65-75% of 10 RM) Volume: 15 sets of 8-10 repetitions
Weeks 9-12
Further increase to high intensity (80-90% of 10 RM) Volume: 15 sets of 6-8 repetitions
Weeks 13-16
High-intensity (95-105% of 10 RM) Volume: 15 sets of 3-5 repetitions
Safety and Monitoring

All sessions are supervised by trained professionals to monitor form, intensity, and safety. Feedback and Adjustments: Regularly check in with participants to assess their comfort, fatigue levels, and any adverse effects. Adjust the intensity as needed based on individual responses.

Assessment

Cognitive Performance Tests
Backward digit span for working memory and MDS-UPDRS
MRI
To measure creatine levels in the brain and assess neuroprotective effects.
Blood Biomarkers
IGF-1, BDNF, osteocalcin, and oxidative stress markers.

References

I Solved Hundreds of LeetCode Problems.

I solved hundreds of LeetCode problems (user: dhtmlkitchen). I would solve the daily problem, then create a write up on LeetCode (because if you can’t explain it, you don’t really understand it that well yourself). Next, I would take screenshots of my code, copy the problem description, and post the problem with my screenshots on LinkedIn. 

After several months of doing this, I built up a following of about 155 followers.

LinkedIn Sucks

But LinkedIn groups were full of spam and many low-quality posts. Recruiters aren’t there looking to see who’s the best of the best because it’s all spam and low-quality posts. And for the spam, the only actions LinkedIn Trust & Safety take are against the user who reported, blocking and restricting the reporter and leaving the spam.

Johnson & Johnson & Getting Banned

LinkedIn kept feeding me Johnson and Johnson ads, which is a bit of a sore spot for me. So, I broke my rule of posting only professionally-related things on LinkedIn and posted a comment in the comment box of the J&J ads LinkedIn was targetting me with. 

The comment was to the effect that my mother used Johnson and Johnson shower to shower talc products for the 20 years leading up to her diagnosis with leiomyosarcoma, caused by those products[1].

Johnson and Johnson recently settled a massive lawsuit for these products. However, because leiomyosarcoma is so rare, it was not listed on the lawsuit and I was excluded as a plaintiff.

I was very careful to remain within the guidelines of LinkedIn’s terms.

However, after that, LinkedIn deleted my account.

Interview Prep Matters…

I failed my 2009 Google interview after failing to solve Product of Array Except Self. It’s a challenging dynamic programming problem but once you know how to solve it, it’s not that hard.

…For the Interview

Only a small percentage of technical interview prep has direct practical relevance to the tasks I’ve performed as a Frontend engineer. Some algorithmic problems I’ve had to address as a front end engineer involve n-ary trees, graphs, strings and arrays, which appear on LeetCode. Other algorithms I’ve had to tackle do not. For example, I’ve never seen colorimetry problems on LeetCode.

Other front-end problems involve design patterns, data sanitization strategies, and using strategies to deal with a dynamic deployment environment (web browsers).

[1] https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8106926/#T3

Prefix and Suffix Arrays

A Prefix Array, also known as a Prefix Sum Array or Cumulative Sum Array, is an Array with the calculation of cumulative sums of elements in a source array. It stores the cumulative sum of elements up to a certain index in the array. This can also be done in-place, so that the target rewrites values of the source.

Prefix and Suffix arrays are useful for range computations. For example, LeetCode 1608. Special Array With X Elements Greater Than or Equal X

Here’s how it works:

Given an array of numbers, the prefix array would be another array where each element prefix[i] stores the sum of elements from index 0 to index i in the array.

For example, given nums = [1, 2, 3, 4, 5], the prefix array would be [1, 3, 6, 10, 15], because:

prefix[0] = 1                      // sum from nums[0] to [0]
prefix[1] = 1 + 2 = 3              // sum from nums[0] to [1]
prefix[2] = 1 + 2 + 3 = 6          // sum from nums[0] to [2]
prefix[3] = 1 + 2 + 3 + 4 = 10     // sum from nums[0] to [3]
prefix[4] = 1 + 2 + 3 + 4 + 5 = 15 // sum from nums[0] to [4]
Code language: JavaScript (javascript)

Here is an example of creating a prefix array in-place, in JavaScript:—

const nums = [1, 2, 3, 4, 5];
nums.forEach((num, i) => nums[i] += nums[i-1] ?? 0);
// [1, 3, 6, 10, 15]
Code language: JavaScript (javascript)

Suffix Array:

A suffix array is similar to a prefix array, but it stores cumulative sums in reverse order. Instead of storing the sum of elements up to a certain index from left to right, a suffix array stores the sum of elements from right to left.

Given the array nums = [1, 2, 3, 4, 5], the suffix array would be:—

suffix[4] = 5
suffix[3] = 5 + 4 = 9
suffix[2] = 5 + 4 + 3 = 12
suffix[1] = 5 + 4 + 3 + 2 = 14
suffix[0] = 5 + 4 + 3 + 2 + 1 = 15

//  [15, 14, 12, 9, 5]
Code language: JavaScript (javascript)

Suffix Array Code

Creating a suffix array function is a little trickier than writing a prefix array. It can be done with a new array or in-place, replacing values of an existing array. Here are both.

function createSuffixArray(nums) {
    const suffixArray = new Uint32Array(nums);
    for (let i = suffixArray.length - 2; i >= 0; i--) {
        suffixArray[i] += suffixArray[i+1];
    }
    return suffixArray;
}

const nums = [1, 2, 3, 4, 5];
createSuffixArray(nums);
// [15, 14, 12, 9, 5]
Code language: JavaScript (javascript)

By pre-allocating a Uint32Array of the appropriate length and iterating over the input array from right to left, I efficiently compute the cumulative sums and store them directly in the suffix array without needing to reverse the array or create intermediate copies. This approach is concise and efficient.

This can also be done in-place.

function createSuffixArrayInPlace(nums) {
    for (let i = nums.length - 2; i >= 0; i--) {
        nums[i] += nums[i+1];
    }
    return nums; // Optional: Return the modified nums array
}

const nums = [1, 2, 3, 4, 5];
const suffixArray = createSuffixArrayInPlace(nums);
// [15, 14, 12, 9, 5]
Code language: JavaScript (javascript)

Applicant Tracking Systems and User Privacy

Applicant tracking systems (ATS) help companies streamline the hiring process.

Although these tools are important for larger companies, unwanted data sharing, blacklisting, and hiring bias can impact job seekers.

But first, some of the benefits of ATSs.

ATSs make it easier for hiring teams to manage and track candidates through the hiring process from start to finish, consolidate and maintain candidate data in one place, automate tasks such as resume screening, scheduling, saves time and reduces costs.

ATSs are scalable. They adapt to the hiring process as needed, handling large volumes of applications and candidates with ease.

They also provide a broader pool of candidates, including passive candidates who might not be actively looking for a job, but can be searched. And there’s the rub.

Privacy and Discrimination Concerns

Applicant data can be shared both within the company and globally, between partner organizations that use the same applicant tracking system.

Applicant data can include resumes, application materials, and notes on candidate interactions to alert companies about concerns regarding qualifications or behavior.

Various attributes within applicant tracking systems (ATS) can be deemed undesirable or potentially harmful to candidates. This information is internal and not publicly accessible.

Some of these negative attributes include “Do Not Hire” flags, negative comments by recruiters or hiring managers, and low compatibility scores determined by algorithms.

People can be unofficially blacklisted by being placed on “do not hire” lists or by having negative notes or attributes associated with their profiles in multiple applicant tracking systems.

Employers that use applicant tracking system generally require applicants use them. Companies may choose to make accommodations for employees who choose not use the ATS but few companies make such exceptions.

To work as an employee at a larger company, one will most likely be required to use the company’s ATS.

Participation in this system means allowing companies to share one’s data among a global network of companies. That can compromise privacy and ultimately impact future employability.

My experience with Applicant Tracking Systems includes being invited to an interview, then being forced to answer a laundry list of demographic questions through ADP, and then being promptly excluded from the interview process. (I’m currently trying to sort this out with ADP.)

LeetCode 1289. Minimum Falling Path Sum II

DP Solution Without Modifying Input — 24 Lines — O(n^2) / O(n)

Problem: https://leetcode.com/problems/minimum-falling-path-sum-ii/

Solution: https://leetcode.com/problems/minimum-falling-path-sum-ii/solutions/5081680/dp-solution-without-modifying-input-24-lines-o-n-2-o-n/

Algorithm

  1. Find smallest two cells of first row.
  2. Loop through remaining rows, rows i+1 to len-1.
  • For each cell, if it’s not the same col index as the prev smallest, add smallest prev cell, low, else, add the second smallest prev, hi.
  • Find next two lowest cells for each next row after adding lowest cells from prev row
  1. Return last lowest cell

Complexity

  • Time complexity: O(n2)
  • Space complexity: O(n)

The lowest values of the prev row are stored in three properties, low, i, hi.

rowValues = {
  low // lowest value (from prev row)
  hi // second lowest value (from prev row
  i // lowest value's index (from prev row)
}

The values of each row are also temporarily stored in an identically-structured object.

const minFallingPathSum = (() => {
    "use strict";
    const findLeastTwo = (row, prev) => {
        const rowValues = { low: Infinity, hi: Infinity };
       for (let i = 0; i < row.length; i++) {
            let cell = row[i] + (i === prev.i ? prev.hi : prev.low);
            if (cell < rowValues.low) { 
                 Object.assign(rowValues, {hi:rowValues.low, low:cell, i:i});
            } else if (cell < rowValues.hi) {
                rowValues.hi = cell;
            }
        }
        Object.assign(prev, rowValues);
    };

    return grid => {
        const prev = { low: 0, hi: 0, i: -1 }
        for (const row of grid) findLeastTwo(row, prev);
        return prev.low;
    };
})();Code language: JavaScript (javascript)

Top-Level Array filter with Function.prototype.call.bind

Top-level Array generics didn’t make it into EcmaScript. Here’s how to hand-roll them.

const myFilter = Function.prototype.call.bind(Array.prototype.filter);
Code language: JavaScript (javascript)

And that gives is a function that can be called as:—

const isNotUpper =  e=>e>"Z"; // lexicographic comparison
myFilter("asdAxE", isNotUpper).join(""); // "asdx"
Code language: JavaScript (javascript)

How does this filter “magic” work? Let’s look step-by-step with another example, Array.prototype.forEach. But first, let’s get some “basics” out of the way.

Function.prototype.call

Function.prototype.call calls the function it’s called on, passing its first argument as the this value to that function.

In the following example, window.prompt is called three times, passing the value of each character, followed by the index in which it occurs, followed by the this value (a String object).

[].forEach.call("asd", prompt);
Code language: JavaScript (javascript)

The interpreter will execute the above as the following:

thisArg = new String("asd");

prompt("a", 0, thisArg);
prompt("s", 1, thisArg);
prompt("d", 2, thisArg);
Code language: JavaScript (javascript)

(Function window.prompt ignores the last argument.)

We can do likewise with console.log, which prints any number of arguments.

[].forEach.call("asd", console.log);
Code language: JavaScript (javascript)

image
In each call, the arguments passed are (1) the value at each index, (2) the index, and (3) the String object (promoted from a string value), used as the thisArg.

Function.prototype.call.call

We can further abstract the forEach call with:—

Function.prototype.call.call (func, thisArg, ...args )
Code language: JavaScript (javascript)

— as:—

Function.prototype.call.
    call([].forEach, "asd", console.log)
Code language: JavaScript (javascript)

— resulting:—

image

In the above code, the this value to call is [].forEach, the this value to forEach is "asd", promoted to a String object, and the callback function, the first argument to forEach, is console.log.

Function.prototype.call.bind

If the second call method is replaced with call to Function.prototype.bind, forEach will be bound as the this value to a function from call as:—

let arrayForEach = Function.prototype.call.bind([].forEach);
Code language: PHP (php)

The steps by which this new function is created are a bit tricky, but it essentially creates a new function with a `[[BoundThis]] value assigned to the first argument (promoted to an object) (See: 10.4.1.3 BoundFunctionCreate ( targetFunctionboundThisboundArgs )).

The forEach method can now be called generically, without call.

arrayForEach("asd", console.log)
Code language: JavaScript (javascript)

The bound function arrayForEach is passed with "asd", which is promoted to a string object with length=3, and used as the this arg for [].forEach. Function [].forEach is called with, console.log three times, such as:

console.log(thisArg[i], i, thisArg)
Code language: JavaScript (javascript)
image

We can reuse this top-level Array.prototype.forEach:

const arrayForEach = 
Function.prototype.call.bind([].forEach);
arrayForEach("asd", console.log)
arrayForEach("qwe", console.log)
Code language: JavaScript (javascript)
image

Function.prototype.call Shortcut

Just as Array.prototype.forEach is found on every array instance such as [].forEach, so too is Function.prototype.call found on every function instance, such as (function(){}).call.

Base Object to Call and Arrow Functions

Arrow functions get their this value from the lexical environment and Bound functions have a bound thisArg (more on this later). This:—

(e=>e).call("foo")
Code language: JavaScript (javascript)

— results undefined

For our intent, this doesn’t matter. We can still use call a layer of abstraction out, as call.call. We don’t access the Base object that far back. We can also use other functions or the built-in function constructor function, Function.

(function(){return this}).call({})
Code language: JavaScript (javascript)

— which returns the object argument, {}.

Calling of forEach is stored by binding forEach to the call method:

let boundForEach = Function.prototype.call.bind([].forEach);
Code language: JavaScript (javascript)

This can be later called with any thisArg and any callback.

boundForEach("asd", prompt);
Code language: JavaScript (javascript)

Bound Method for Array.prototype.filter

Back to the problem at hand, we want to invoke Array.prototype.filter when it’s called and with the arguments passed in:

const myFilter = Function.prototype.call.bind(Array.prototype.filter);
Code language: JavaScript (javascript)

And that gives is a function that can be called as:—

const isNotUpper =  e=>e>"Z"; // lexicographic comparison
myFilter("asXd", isNotUpper);
Code language: JavaScript (javascript)

— results:—

['a', 's', 'd']
Code language: JavaScript (javascript)

Function myFilter is called with array-like object to act as the this value for the actual function call to Array.prototype.filter.Array.prototype.filter promotes its thisArg to a String object and calls the second parameter, isNotUpper (with that String as the thisArg).

Just as we get Array.prototype.forEach with [].forEach, so too can we get Function.prototype.call from any function (except arrow or bound functions).

Function.call is the same Function.prototype.call, but gets it this arg a Function, the base object, if called as Function.call(). As mentioned, we’re not calling it like that, rather, we’re using the value of that function as the Base object for bind.

From: https://leetcode.com/problems/filter-elements-from-array/discuss/5024144/Function.prototype.call.bind

Checking NaN Values

NaN is a global property that represents an IEEE 754 “not a number”. (There is also a static NaN property of the built-in Number object, Number.NaN for pointless duplication (mdn)).

In older versions of ECMAScript NaN and other global properties like undefined were writable. You shouldn’t be doing that and Brendan, et al made it illegal; even throwin errors in strict mode..

The value type of NaN is “number”, as can be seen by the literal NaN property or by NaN values.

typeof NaN; // "number"
typeof (1 / "foo"); // "number"

Any value compared to NaN using the comparison operators == or === results false.

NaN == NaN; // false
undefined == NaN; // false

Method isNaN almost seems to work:—

isNaN(NaN); // true

— until it does type conversion, even attempting to run the algorithm when no argument is supplied.

isNaN(); // true
isNaN(undefined); // true
isNaN("-."); // true
isNaN(""); // false
isNaN("-2."); // false

The answer to that is to use Number.isNaN, which only returns true for actual NaN values and does not do type conversion.

Number.isNaN(); // false
Number.isNaN("1"); // false
Number.isNaN(""); // false
Number.isNaN("-."); // false
Number.isNaN("0xf"); // false
Number.isNaN("-2."); // false

Object.is can also reliably check NaN values:

 Object.is(NaN, NaN); // true
 Object.is(NaN, undefined); // false

Methods isFinite and the newer non-type-converting version Number.isFinite can work in certain situations:—

 Number.isFinite(NaN); // false

— but do not check exclusively for NaN, as they also return true for Infinity and -Infinity:—

 Number.isFinite(-Infinity); // false

But these methods are useful for numeric validation. Especially Number.isFinite, which, unlike global isFinite, does not do type conversion:

Number.isFinite("2"); // false
Number.isFinite(new Date); // false
isFinite("2"); // true
isFinite(new Date); // true

Teach Yourself to Speak

Have you considered learning English?

Your communication skills might not be as good as you think they are.

The greater burden of communication lies upon the one communicating the message. If you want to be understood, it is your duty to clearly and effectively communicate your intended meaning to your audience.

You don’t need school. All you need is your brain, a camera, and the will to speak well. Learn to speak by making videos of yourself speaking and watching them back.

LeetCode 15. 3Sum, in JavaScript

Problem

LeetCode 15. 3Sum — JavaScript.

Solution

https://leetcode.com/problems/3sum/solutions/2895033/javascript-sorted-typed-array-sliding-window/?orderBy=most_votes

const threeSum = numsArray => {
    "use strict";
    const nums = Int32Array.from(numsArray).sort();
    const results = [];
    const LAST  = nums.length - 1;

    let i = 0;
    do {
        const n = nums[i];
        if (n === nums[i-1]) continue;
        let l = i + 1;
        let r = LAST;
        const isPossible = (n + nums[l] + nums[l+1] <= 0);
        if (!isPossible) break;
        do {
            const ln = nums[l];
            const rn = nums[r];
            const testSum = n + ln + rn;

            if (testSum === 0) {
                results.push([n, ln, rn]);
                // Increment l; decrement r.
                // To avoid duplicate triplets,
                // repeat until unique values appear.
                //  E.g. [-10, 2, 3, 3, 7, 8]
                // [[-10, 2, 8] [-10, 3, 7]] NOT 2nd [-10, 3, 7]
                while (ln === nums[++l]);
                while (rn === nums[--r]);
            } else if (testSum < 0) {
                l++;
            } else {
                r--;
            }
        } while (l < r);
    } while (++i < LAST)
    return results;
};Code language: JavaScript (javascript)

Interactive Web Demo in JavaScript

https://mybanned.com//wp-content/uploads/2023/01/3sum.html

Video