Composition in Javascript | Javascript Interview Questions

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025
  • Closure in Javascript: • Closure in Javascript
    Currying in Javascript: • Currying in Javascript...
    In this video, we'll explore the concept of composition function in Javascript.
    Connect With Me: bio.link/piyus...
    More Playlists
    ► Complete ReactJS Tutorial Series - • Complete React Tutoria...
    ► Complete Firebase & React Tutorial Series - • Firebase with Reactjs ...
    Social Links
    ► Twitter - / piyushgarg_dev
    ► LinkedIn - / piyushgarg195
    Video Titles
    What is currying in Javascript?
    Javascript Composition
    Javascript Composition Functions
    Javascript Interview Questions
    Hashtags
    #javascript #closure #currying #javascriptcurry #webdev #webdeveloper #javascriptinhindi #javascriptinterviewquestions #webdevelopment #javascriptinhindi

Комментарии • 24

  • @FaizanKhan-gfaizank
    @FaizanKhan-gfaizank Год назад +7

    Key takeaways from the video:-
    To compose two functions accepting two arguments, following can be done:-
    function composeTwo(fn1, fn2){
    return function(a, b){
    return fn2(fn1(a,b));
    };
    }
    In ES6, the same can be written as, const c2f=(fn1, fn2) => (a,b) => fn2(fn1(a,b));
    and for composing unlimited functons, we can do the following:-
    function compose(...fns){
    return function(...values){
    return fns.reduce( (a,b) => b(a), value);
    };
    }

  • @PratikPatil-yv6he
    @PratikPatil-yv6he 5 месяцев назад +1

    leetcode par js ke problems solve kar raha tha function compositions se related question aaya youtube pe search kiya bhaiya ka video dikha aur pura concept samaz mein aagaya ab question solve karunga
    👌😊

  • @codingwave56
    @codingwave56 Год назад +10

    😏You Did Not Taught Us Well...
    8:56 You Got Stuck...Where You Used reduceRight...
    and After It You Cutted Your Video
    And Solved By Making It "reduce" function... and you didn't even Mention About It...
    This Is Where I Also Stuck And THinking Why Your Code Is Working And Mine Not.................................
    At Least Smjana To Chye Tha Ki Kyu Erroor Aa rhi thi aur kyu reduceRight Function ki jgh reduce function ka use karna pda....
    Sorry,,,But You Are Teaching Next Level,,,,But I Have Head Ache rn. so please Give Answer The My q's.... if possible 🙏🏼❤

    • @AshirvadiNathDwivedi
      @AshirvadiNathDwivedi 5 месяцев назад

      const addition = (...number) => {
      return number.reduce((acc, curr) => acc + curr, 0);
      };
      const subtraction = (...number) => {
      return number.reduce((acc, curr) => acc - curr, 0);
      };
      const multiplication = (...number) => {
      return number.reduce((acc, curr) => acc * curr, 1);
      };
      const division = (...number) => {
      return number.reduce((acc, curr) => acc / curr, 1);
      };
      const square = (number) => {
      return number * number;
      };
      const compose =
      (...fns) =>
      (...args) => {
      return fns.reduceRight((acc, fn) => [fn(...acc)], args)[0];
      };
      const number = [1, 2];
      const addAndSquare = compose(square, multiplication);
      console.log(addAndSquare(...number));

  • @VijayDChauhaan
    @VijayDChauhaan 2 года назад +6

    Great Explanation , I mean Effortless, You are Natural bro

  • @VarunMalik-mo6mr
    @VarunMalik-mo6mr 9 месяцев назад +3

    Bhaiya you’re best the way you narrate these complex concepts in a story way hats off❤️

  • @jaigangemata4166
    @jaigangemata4166 10 месяцев назад +3

    ohhh! I am just a beginner, who was following your series, but this is the only lecture which has gone total parabola over my head. Shit! JS is complex.......

  • @AshirvadiNathDwivedi
    @AshirvadiNathDwivedi 5 месяцев назад

    Great Tutorial Thank U

  • @gouravojha1353
    @gouravojha1353 6 месяцев назад

    Maza aagaya

  • @amitk9843
    @amitk9843 11 месяцев назад

    hello ... I didnt get line number 21 ... you said b ke andar a ko wrap karna hai .... what is it .. could you please explain

    • @amitk9843
      @amitk9843 11 месяцев назад

      ok I got it .. i was getting confused by assuming a and b as arguments (as in first half of the video both are referred as argument) ... but you are referring it as functions when you strated unlimited functions and arguments concept

  • @mohammedshahed5051
    @mohammedshahed5051 4 месяца назад

    Bhai Square function is supposed to square a number not multiply any two numbers!

  • @sayannandi1526
    @sayannandi1526 7 месяцев назад

    sir unlimited composition ke liye console mai NaN show kar raha hai.....code mai koi galti nahi hai ....I checked

    • @AshirvadiNathDwivedi
      @AshirvadiNathDwivedi 5 месяцев назад

      const addition = (...number) => {
      return number.reduce((acc, curr) => acc + curr, 0);
      };
      const subtraction = (...number) => {
      return number.reduce((acc, curr) => acc - curr, 0);
      };
      const multiplication = (...number) => {
      return number.reduce((acc, curr) => acc * curr, 1);
      };
      const division = (...number) => {
      return number.reduce((acc, curr) => acc / curr, 1);
      };
      const square = (number) => {
      return number * number;
      };
      const compose =
      (...fns) =>
      (...args) => {
      return fns.reduceRight((acc, fn) => [fn(...acc)], args)[0];
      };
      const number = [1, 2];
      const addAndSquare = compose(square, multiplication);
      console.log(addAndSquare(...number));

  • @ajayypalsingh
    @ajayypalsingh Год назад +2

  • @amankumarsharma3187
    @amankumarsharma3187 10 месяцев назад +1

    can't we write like this ? type Add = (a:number,b:number) => number
    const add:Add = (a,b) => a+b
    type Square = (a:number) => number
    const square =(a) => a*a
    const flow = (f,g) => (x,y) => f(g(x,y))
    const add_then_square = flow(square,add)
    console.log(add_then_square(2,4))
    in functional programming first we should define the type of each method , each variable .

    • @muditkhanna8164
      @muditkhanna8164 10 месяцев назад

      nope you're not just writing add and square all the time, it was just an example ,in real these composition technique can be used in hashing algos, string matching etc
      try writing this your way,fn(double(poweroftwo(add(removeodds(...args)), this is currently written in python, but if i have to rewrite it in javascript i would definitely use composition.
      normal devs won't encounter them , but those who write tools for devs use them.

  • @theia1357
    @theia1357 Год назад

    thanks

  • @rhishikeshc60
    @rhishikeshc60 Год назад

  • @mrharshad2000
    @mrharshad2000 Год назад +3

    mai next js ka latest version ka use karke ek full stack e-commerce webapp ka tutorial banane ka soch raha hu iss video me html, css, javascript, node js , mongodb, redis, redux toolkit, cloudnery sabhi ka use kab, kyo, aur kaise ek sath use karna sikhenge aur iss app ko vercel ke server par free me deploy bhi karega agar mere comment me 200 likes hota hai to Mujhe RUclips par video banane ka motivation milega

  • @vandanayadav1035
    @vandanayadav1035 Год назад +1

    thanks