duckduckgo
duckduckgo

Reputation: 1295

How is this JS code explained

I have a js file (requirejs api) which i am trying to understand, but unable to get any meaning

First few lines:

var requirejs,require,define;
(function(ba){
    function J(b){
        return"[object Function]"===N.call(b)
        }
        function K(b){
        return"[object Array]"===N.call(b)
        }
        function z(b,c){
        if(b){
            var d;
            for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);
        }
    }
    function O(b,c){
    if(b){
        var d;
        for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);
    }
}

the parent page loading this js has a call to method require() but i dont see any such function definition in entire file. And then how is argument ba treated? is "b" coming from ba? Is this file made of obfscation? all functions are named like a() , b() etc

Upvotes: -1

Views: 112

Answers (1)

VisioN
VisioN

Reputation: 145458

This is a minified version of RequireJS. Just open the full version with comments:

http://requirejs.org/docs/release/2.1.6/comments/require.js

During the minification, in order to save bytes, variable names are often replaced with the short ones. For instance, here J(b) refers to method isFunction(it) and K(b) to isArray(it), while z(b,c) looks like each(ary, func) and O(b,c) is eachReverse(ary, func).

Upvotes: 1

Related Questions