What is typeof exports === 'object' && typeof module === 'object'? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is typeof exports === 'object' && typeof module === 'object'?

Hey! I saw this piece of code in any javascript code of a website or libraries like jQuery. Code : if(typeof exports === 'object' && typeof module === 'object'){ module.exports = factory(); } else if (typeof define === 'function' && define.amd) { define([], factory); }

29th Jul 2021, 8:23 AM
Coder-Rohit[{(∞)}]
Coder-Rohit[{(∞)}] - avatar
5 Answers
0
typeof returns the type of the variable. So "typeof exports" returns the type of the variable exports.
27th Aug 2021, 4:20 PM
Knäcke Brot
Knäcke Brot - avatar
0
Knäcke Brot what is amd
28th Aug 2021, 1:09 AM
Coder-Rohit[{(∞)}]
Coder-Rohit[{(∞)}] - avatar
0
You mean the manufactor of CPUs?
28th Aug 2021, 5:42 AM
Knäcke Brot
Knäcke Brot - avatar
0
Knäcke Brot no, Asynchronous module definition (AMD)
28th Aug 2021, 12:37 PM
Coder-Rohit[{(∞)}]
Coder-Rohit[{(∞)}] - avatar
0
I don't know, but I think this could help you... https://github.com/amdjs/amdjs-api/wiki/AMD
28th Aug 2021, 12:57 PM
Knäcke Brot
Knäcke Brot - avatar