1

completely new to reactJS, I wanted to understand what (0, c.default) is doing on this code snippet. the code apparently converts hexadecimal value to Base64. but before converting it to the Base64 it was converted as string then but I didn't understand what this code doing (0, c.default)?

Here is the code snippet


f = t.type + "&" + encodeURIComponent(t.url) + "&" + n + "&" + u + "&" + b + 
                                "&LS8goCQy4O2w5xnPmEOp/PjtKe37+d9HxRthqug9VC0=";
sig = hexToBase64((0, c.default)(f).toString())

Here is the code snippet of the method hexToBase64()

hexToBase64: function (o) {
                return t.btoa(String.fromCharCode.apply(null, o.replace(/\r|\n/g, "").replace(/([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" ")))

hanan
  • 532
  • 2
  • 7
  • 23
  • 2
    Did you read e.g. https://stackoverflow.com/q/32275135/3001761? – jonrsharpe Apr 19 '20 at 16:31
  • 2
    It's basically `c.default.call(globalThis, f).toString()`. Essentially it ensures that `c.default`'s `this` will not be `c` as it would normally be when writing `c.default(f)`, but the global `this` (`globalThis` in modern JS, same as e.g. `window` in a browser). – CherryDT Apr 19 '20 at 16:36
  • @CherryDT thanks for the clarification, now I can understand it. – hanan Apr 19 '20 at 16:39

0 Answers0