Composition in Javascript | Javascript Interview Questions

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024
  • 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

  • @VarunMalik-mo6mr
    @VarunMalik-mo6mr 6 หลายเดือนก่อน +3

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

  • @FaizanKhan-gfaizank
    @FaizanKhan-gfaizank ปีที่แล้ว +6

    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);
    };
    }

  • @VijayDChauhaan
    @VijayDChauhaan ปีที่แล้ว +5

    Great Explanation , I mean Effortless, You are Natural bro

  • @PratikPatil-yv6he
    @PratikPatil-yv6he หลายเดือนก่อน +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
    👌😊

  • @jaigangemata4166
    @jaigangemata4166 6 หลายเดือนก่อน +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 หลายเดือนก่อน

    Great Tutorial Thank U

  • @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 หลายเดือนก่อน

      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));

  • @vandanayadav1035
    @vandanayadav1035 9 หลายเดือนก่อน +1

    thanks

  • @mohammedshahed5051
    @mohammedshahed5051 หลายเดือนก่อน

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

  • @amankumarsharma3187
    @amankumarsharma3187 7 หลายเดือนก่อน +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 7 หลายเดือนก่อน

      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.

  • @amitk9843
    @amitk9843 7 หลายเดือนก่อน

    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 7 หลายเดือนก่อน

      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

  • @ajayypalsingh
    @ajayypalsingh ปีที่แล้ว +2

  • @gouravojha1353
    @gouravojha1353 2 หลายเดือนก่อน

    Maza aagaya

  • @sayannandi1526
    @sayannandi1526 3 หลายเดือนก่อน

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

    • @AshirvadiNathDwivedi
      @AshirvadiNathDwivedi หลายเดือนก่อน

      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));

  • @mrharshad2000
    @mrharshad2000 9 หลายเดือนก่อน +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 TH-cam par video banane ka motivation milega

    • @pranavmagdum5495
      @pranavmagdum5495 3 หลายเดือนก่อน

      waiting for your video bro😂

  • @rhishikeshc60
    @rhishikeshc60 ปีที่แล้ว

  • @krutikabarad4241
    @krutikabarad4241 9 หลายเดือนก่อน

    thanks