Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
1 vote
2 answers
61 views

I'd like to define a type that will only allow nonempty binary strings. Something like: type BinChar = "0" | "1" type BinString = `${BinChar}${BinString}` const b: BinString = &...
Jean-Philippe Pellet's user avatar
0 votes
0 answers
34 views

I'm trying to invoke my lang files (i.e. en.json, es.json, etc.) within a Javascript template literal however, when I call upon the lang file using Handlebars, it renders the lang call as a string ...
Deo3560's user avatar
  • 45
0 votes
0 answers
13 views

I'm learning JavaScript, absolute beginner here. I'm trying to get my first Template Literal to work. For example: const firstName = "john" const person1 = `He's &{firstName}`; What I ...
V P's user avatar
  • 19
1 vote
2 answers
64 views

In principle (T & Record<K, U>)[K] should evaluate to U but it doesn't seem to work in the case where K is generic and extends a template literal. function foo3< K extends `a${string}`...
Exifers's user avatar
  • 2,932
-2 votes
3 answers
88 views

I have this code: const newDiv = document.createElement('div'); newDiv.innerHTML = ` <button class='btn btn-download'> <span class='icon'>&#...
Shibaji Biswas's user avatar
2 votes
1 answer
146 views

Im trying to make an AJAX call to a servlet from a login page which is designed as a '.jsp' page. Im using 'fetch' API for AJAX (code snippet attached below). This script is written in same '.jsp' ...
D.Malim's user avatar
  • 128
-1 votes
2 answers
70 views

I still don’t understand the use of embedding HTML into javascript code. I understand the use of template literals to insert HTML but still not understand why is there a need to embed HTML. Please ...
Esha's user avatar
  • 1
0 votes
1 answer
45 views

i got a string, which is from user input, i store it in a variable say, str let str = "some user generated better string that contains unicode escapes \u1451 \u3516 with some otehr escapes \n \t \...
Arnav Kumar's user avatar
1 vote
1 answer
80 views

My code is working well in Chrome but not in Firefox. When I search path element using querySelector with attribute Firefox gives an error that path is not found. defs.appendChild(svgGradient); const ...
Muhammad Amir's user avatar
1 vote
3 answers
91 views

Whenever i am trying to run below line of code, its not executing <br> as break line but actually executing it as string. const firstFiveLetters = chartData.centerText.slice(0, 5); const ...
Puja Bhandari's user avatar
0 votes
1 answer
51 views

I want to be able to basically do this let x = 1; let `arr${x}`; if ((i = 0)) `arr${x}` = []; `arr${x}`.push(words); console.log(`arr${x}`); I have tried using eval() let x = 1; eval(`let arr${x}`); ...
huz3y's user avatar
  • 21
1 vote
1 answer
61 views

Given // GIVEN type Animal<T extends string> = { id: T, } type Dog = Animal<"animal.dog"> & { foo: string } type Cat = Animal<"animal.cat"> & { ...
Maxime Lechevallier's user avatar
1 vote
1 answer
309 views

I have the following component: function SaleBadge({ textContent, badgeColor }) { return ( <Badge className={`bg-${badgeColor}-200 hover:bg-${badgeColor}-300 animate-pulse align-middle ...
Kristoffer Andersson's user avatar
0 votes
2 answers
71 views

I am trying to dynamically call a function based on its name stored in a string using bracket notation on the window object. I have also tried using eval() to no success. The project has been bundled ...
Laurence B's user avatar
1 vote
1 answer
49 views

In the example below there is an inline event handler that is not working, because there is something wrong with escaping characters. In general inline handlers are bad practice and difficult to ...
Murmulodi's user avatar
  • 739

15 30 50 per page
1
2 3 4 5
38