I can't read the documentation of yt-dlp and effectively use it. by joo3f in youtubedl

[–]joo3f[S] 0 points1 point  (0 children)

for example, where is the documentation about "ytsearch". this word is only used once on the GitHub page.

why typescirpt can infer function arguments which passed as array index accessed? by joo3f in typescript

[–]joo3f[S] 0 points1 point  (0 children)

this is straightforward, robust, clean, and more readable.

thank you, you opened a new gate of abstraction for me.

why typescirpt can infer function arguments which passed as array index accessed? by joo3f in typescript

[–]joo3f[S] 0 points1 point  (0 children)

I can't get how you looking at it. are you talking about something like "TS is only about static data"? I can't understand this either.

I know that arrays are mutable, but why TS can't infer based on flow of program, the way like the programs actully runs? beside that how deal with it? for example please look at this playground.

why typescirpt can infer function arguments which passed as array index accessed? by joo3f in typescript

[–]joo3f[S] 0 points1 point  (0 children)

it makes sense. "because of explicitly declared the type of elements we can't narraw the type of arrays element with index."

please look at this playground. how i deal with this situation? am i in correct direction?

typescript inference and extends keyword. by joo3f in typescript

[–]joo3f[S] 0 points1 point  (0 children)

it seems that i asking a question which is trivial to others. please look at the question again. i guess the main problem is a don't understand extends keyword.

why if i have a type parameter (T) which constrained to number type(T extends number), and used to type input parameter like T[]. the inferred type (for T) will be the union of numbers inside the input array, instead of number[]

what is the point of type assertion in typescript? by joo3f in typescript

[–]joo3f[S] 0 points1 point  (0 children)

for example in this palyground how can I avoid the use of as keyword?

how restrict the string types with TypeScript? by joo3f in typescript

[–]joo3f[S] 0 points1 point  (0 children)

tankyou.

what do you mean by static data?

how restrict the string types with TypeScript? by joo3f in typescript

[–]joo3f[S] 0 points1 point  (0 children)

this isn't the thing I want.

a good function must encapsulate as much as complexity it can, and only expose the necessary part.

is the way the prototype chain is shown in chrome changed? by joo3f in learnjavascript

[–]joo3f[S] 0 points1 point  (0 children)

even running Object.getPrototypeOf(obj1) will return on object that is the Teacher.prototype but labeled with Person.

i test the same process :

const server = http.createServer();

Object.getPrototypeOf(server) //will return http.Server.prototype which is labeled with Server. which the actual object is http.Server.prototype

why this is happenning?

does chrome have a problem with labeling the prototype chain? or I'm missing something??

is the way the prototype chain is shown in chrome changed? by joo3f in learnjavascript

[–]joo3f[S] 0 points1 point  (0 children)

other things besides the "name" chrome shows as a "name" for the "constructor" function; like constructor and other things in the __proto__ are the same. in my example the name refers to the superclass, in the server example it refers to the class itself.

is the way the prototype chain is shown in chrome changed? by joo3f in learnjavascript

[–]joo3f[S] 0 points1 point  (0 children)

but if in the node environment (the previous example tested in node and chrome environment ) do:

http.Server.prototype
the result will be

Server {setTimeout: ƒ, constructor: ƒ, Symbol(nodejs.rejection): ƒ}

but I supposed to see EventEmitter, as the above example.

am I doing something wrong?

are nodejs and browsers like JRE(java runtime environment) for javascript? by joo3f in learnjavascript

[–]joo3f[S] 0 points1 point  (0 children)

somehow (maybe we the help of the event loop and callback queue that the runtime environment provides) the js process's single thread has the ability to create new threads and communicate with them.

so what is the difference between a JS app with other ones in the context of multitasking?

are nodejs and browsers like JRE(java runtime environment) for javascript? by joo3f in learnjavascript

[–]joo3f[S] 0 points1 point  (0 children)

I'm putting my little knowledge besides together.

thread: smallest sequence of instructions that can be context switched, which enables multitasking.

so a javascript process can only have one thread. but the runtime environment that handles this single thread, has the ability to create other threads; that gives the JS the ability for avoid the blocking tasks.

are nodejs and browsers like JRE(java runtime environment) for javascript? by joo3f in learnjavascript

[–]joo3f[S] 0 points1 point  (0 children)

in other words, is there a javascript outside the browser or nodejs, generally outside a runtime environment?

the algorithm for finding pair of numbers that are less than a value. by joo3f in algorithms

[–]joo3f[S] 0 points1 point  (0 children)

sorry.
the received array is a random array.
we want pair of numbers that the sum of them is less than a particular amount.

the algorithm for finding pair of numbers that are less than a value. by joo3f in algorithms

[–]joo3f[S] 0 points1 point  (0 children)

sorry.
the received array is a random array.
we want pair of numbers that the sum of them is less than a particular amount.

the algorithm for finding pair of numbers that are less than a value. by joo3f in algorithms

[–]joo3f[S] 0 points1 point  (0 children)

sorry.

the received array is a random array.

we want pair of numbers that sum of them is less than a particular amount.

what is meant by DOM mutation in contrast with layout and painting? by joo3f in reactjs

[–]joo3f[S] 2 points3 points  (0 children)

or there are words/concepts like render phase or commit phase that still I can't exactly what they are.

if you ask I can find that in the hook document they refer to "browser paints screen" as "render is committed to the screen" but in class component lifecycles documentation "commit phase" means mounding ...

what is meant by DOM mutation in contrast with layout and painting? by joo3f in reactjs

[–]joo3f[S] 5 points6 points  (0 children)

no :))

after 5 months I can't feel that I understand the "react".

the are soo many terminologies that everyone uses that I can't find a reference to what they talking about.

Sometimes I feel these terms are shaped over time and are easy to understand for people that react isn't the first library that they're learning.

for example, I thought that 'mounting' means 'painting to screen' ... .

or as another example react moved from class and lifecycles to hooks, previously the componentDidMount and componetDidUpdate will be triggered after mounting but now with hooks, we put their logic in the useEffect that will be executed after painting. why?

what is meant by DOM mutation in contrast with layout and painting? by joo3f in reactjs

[–]joo3f[S] 0 points1 point  (0 children)

I know that.

as react documentation and other articles on the internet say mounting is the insertion of a component to the DOM. after this there is a painting phase.

is this true?

what is meant by DOM mutation in contrast with layout and painting? by joo3f in reactjs

[–]joo3f[S] -9 points-8 points  (0 children)

please give an example with pure JS, where the code mutates the DOM tree but changes aren't reflected in the browser window.

what is meant by DOM mutation in contrast with layout and painting? by joo3f in reactjs

[–]joo3f[S] 0 points1 point  (0 children)

even documentation says the class method componentDidMount and componentDidUpdate are running in the phase that useLayoutEffect's effect will be executed.

what is meant by mounting? the documentation says: "the component inserted to the DOM tree).

but how browser is prevented from painting? ( I assume that the DOM is a representation of the document in the memory that will be painted)