A
A
Alexander Andreev2018-02-22 09:40:27
JavaScript
Alexander Andreev, 2018-02-22 09:40:27

What is the approach to writing js?

We are running a project, before us it was made by an office from the top 10 studios in Russia. Source codes were not given, on hand there are only obfuscated and minified js and css files. I got into js-ku and something put me in a stupor)) Here is a code example:

h = function(t) {
                function e(t) {
                    a(this, e);
                    var n = o(this, (e.__proto__ || Object.getPrototypeOf(e)).call(this, t));
                    return n.favoriteShops = {}, n.nonFavoriteShops = {}, n.$showMoreSel = $("Класс-селектора"), n.lists = {
                        favorite: {
                            selector: "#ИД-селектора",
                            data: n.favoriteShops
                        },
                        other: {
                            selector: "#ИД-селектора",
                            data: n.nonFavoriteShops
                        }
                    }, n
                }
                return s(e, t), r(e, [{
                    key: "init",
                    value: function() {
                        l(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "init", this).call(this)
                    }
                }, {
                    key: "bindEvents",
                    value: function() {
                        l(e.prototype.__proto__ || Object.getPrototypeOf(e.prototype), "bindEvents", this).call(this);
                        var t = this;
                        t.$showMoreSel.on("click", function(e) {
                            var n = $(this),
                                i = n.prev("Класс-селектора"),
                                a = i.data("type"),
                                o = t.lists[a].data,
                                s = i.find("Класс-селектора").length,
                                r = 5;
                            t.appendStoreItems(o, r, s, i, "list"), e.preventDefault()
                        })
                    }
                },
        
        /* и дальше идут подобные конструкции { key: имяФункции, value: реализацияФункции } */

I have not come across such an approach before, when using { key: FunctionName, value: FunctionImplementation } . What is it? Self-activity of the developer or is it some kind of approach in writing SPA applications for example? Unfortunately obfuscation complicates understanding even more.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
VoidVolker, 2018-02-22
@VoidVolker

Most likely, the developers wrote the code in ec6 and transpiled (babel and others like it) into ec5 to support IE, because. the result of transpiling ec6-> ec5 usually looks like this.

K
Konstantin Kitmanov, 2018-02-22
@k12th

Very similar to how babel transpiles ES6 classes. (key-values ​​are needed here because it is later fed to a special helper that handles this with Object.defineProperty to better emulate the behavior of methods in ES6 classes.)

T
TheRevan, 2018-02-22
@TheRevan

There are 2 options here:
1. It's just some kind of connected library.
2. After compressing and decompressing the js-ki, it decompressed into an unreadable form

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question