1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

JavaScript The Language(Not Node.js)

Discussion in 'HTML & JavaScript' started by G4143, Jan 27, 2019.

  1. G4143

    G4143 Registered Member

    Joined:
    Jan 16, 2019
    Messages:
    68
    Likes Received:
    29
    Gender:
    Male
    I'm looking for a good (and hopefully complete) tutorial of the browser based JavaScript language. I'm not looking for how the JavaScript language interfaces with an HTML page but the language proper. Basically objects, arrays, dictionaries, higher level functions, variables, looping constructs, etc.
     
  2. redarrow

    redarrow Elite Member

    Joined:
    Apr 1, 2013
    Messages:
    12,055
    Likes Received:
    3,704
    to learn?

    https://www.w3schools.com/js/

    where most learn above.

    we use the javascript manual as well to look deeper.

    https://developer.mozilla.org/bm/docs/Web/JavaScript/Guide

    for more help join a javascript forum

    gd luck

    ps.

    your need to learn also

    javascript
    ajax part of javascript.
    HTML and html5

    there all together

    bootstrap

    it a very long adventure because you update your self as time goes on, there no end point of learning..

    best to master the basics

    you can get self teach book and learn in 24 hours , it all bullshit , i been using javascript / ajax over 14 years and still learning daily, it a lifetime hell.

    my advise learn the code and it meaning dont be a copy and paste programmer study hard .

    when you no the code then copy and paste fully allowed becouse you no it meaning .

    notepad 2 perfect to code with .
     
    • Thanks Thanks x 1
    Last edited: Jan 27, 2019
  3. G4143

    G4143 Registered Member

    Joined:
    Jan 16, 2019
    Messages:
    68
    Likes Received:
    29
    Gender:
    Male
    Well to learn the JavaScript language without all the HTML examples which distract from the main goal.

    Note: I have some experience in several languages like Perl, C, C++, OCaml, etc. So I don't need a NOOBS tutorial but a concise tutorial of the language would be nice.
     
  4. G4143

    G4143 Registered Member

    Joined:
    Jan 16, 2019
    Messages:
    68
    Likes Received:
    29
    Gender:
    Male
  5. G4143

    G4143 Registered Member

    Joined:
    Jan 16, 2019
    Messages:
    68
    Likes Received:
    29
    Gender:
    Male
    Been playing with JavaScript and I'm really impressed how it implements higher order functions and I'm also surprised that most editors allow the programmer to write and execute JavaScript without any HTML. Some messy code I was playing with... A very simple Trie.
    Code:
    "use strict";
    
    function None() {
        this.isSome = false;
        this.bindIt = function (func) { return this; };
    }
    
    function Some(pData) {
        this.data = pData;
        this.isSome = true;
        this.bindIt = function (func) { return func(this.data); };
    }
    
    const none = new None();
    
    function FirstRemainder(first, remainder) {
        this.First = first;
        this.Remainder = remainder;
    }
    
    function getFirstChars(str) {
        let len = str.length;
        if (len > 1) {
            return new Some(new FirstRemainder(str.charAt(0), str.slice(1)));
        } else if (len === 1) {
            return new Some(new FirstRemainder(str.charAt(0), ''));
        } else {
            return none;
        }
    }
    
    function add(trie, str) {
        let chars = getFirstChars(str);
    
        if (chars.isSome) {
            if ((chars.bindIt(function (d) { return d.First; })) in trie) {
                add(trie[chars.bindIt(function (d) { return d.First })], chars.bindIt(function (d) { return d.Remainder }));
            } else {
                let newTrie = {};
                trie[chars.bindIt(function (d) { return d.First })] = newTrie;
                add(newTrie, chars.bindIt(function (d) { return d.Remainder }));
            }
        } else {
            return trie;//don't need this
        }
    }
    
    function find(trie, str) {
        let chars = getFirstChars(str);
    
        if (chars.isSome) {
            if ((chars.bindIt(function (d) { return d.First; })) in trie) {
                return find(trie[chars.bindIt(function (d) { return d.First })], chars.bindIt(function (d) { return d.Remainder }));
            } else {
                return none;
            }
        } else {
            return new Some(trie);
        }
    }
    
    function display(trie) {
        for (let c in trie) {
            console.log(c);
            display(trie[c]);
        }
    }
    
    function strings(trie) {
        let arr = [];
    
        function stringsAux(trie, strs) {
            for (let c in trie) {
                stringsAux(trie[c], strs + c);
            }
            if (Object.keys(trie).length === 0) {
                arr.push(strs);
                strs = "";
            }
        }
    
        stringsAux(trie, "");
        return arr;
    }
    
    let trie = {};
    
    add(trie, "G4143\n");
    add(trie, "This is the first\n");
    add(trie, "This is the second\n");
    add(trie, "This is the third\n");
    add(trie, "This is the fourth\n");
    add(trie, "This is the fourth\n");
    add(trie, "Here it ends...\n");
    //try duplicates
    add(trie, "G4143\n");
    add(trie, "This is the first\n");
    add(trie, "This is the second\n");
    add(trie, "This is the third\n");
    add(trie, "This is the fourth\n");
    add(trie, "This is the fourth\n");
    add(trie, "Here it ends...\n");
    
    let ans = find(trie, "This is the ");
    
    if (ans.isSome) {
        ans.bindIt(function (d) { display(d) });
    } else {
        console.log("Nothing found!");
    }
    
    console.log("Lines...");
    
    let strs = strings(trie);
    
    for (let line in strs) {
        console.log(`Line: ${strs[line]}`);
    }
    
    //display data structure
    
    console.log(JSON.stringify(trie));
    
     
    Last edited: Feb 5, 2019
  6. javabro

    javabro Jr. VIP Jr. VIP

    Joined:
    Dec 2, 2015
    Messages:
    1,350
    Likes Received:
    2,573
    Gender:
    Male
    Occupation:
    They pay me to write code.
    Location:
    Pearl of the Indian ocean
    Home Page:
    • Thanks Thanks x 1
  7. G4143

    G4143 Registered Member

    Joined:
    Jan 16, 2019
    Messages:
    68
    Likes Received:
    29
    Gender:
    Male
    I always heard JavaScript was a mess of a language(one of the reasons I shied away from it) but after reading some introductory text and playing around with it, I have to say its not that bad when you accept its odd object model(well odd for someone who was introduced to OOP with C++).
     
  8. G4143

    G4143 Registered Member

    Joined:
    Jan 16, 2019
    Messages:
    68
    Likes Received:
    29
    Gender:
    Male
    Yes! This language(when you get some of the basics down) is fun to program in and its easy to implement abstractions in. I see why people like this language.
    Code:
    "use strict";
    
    function crtNone () {
        class None {
            constructor() {
                this.isSome = false;
                this.bindIt = function (func) {return this;};
            }
        }
        return Object.freeze(new None());
    }
    
    function crtSome (pData) {
        class Some {
            constructor (pData) {
                this.data = pData;
                this.isSome = true;
                this.bindIt = function (func) {return func(this.data);};
            }
        }
        return Object.freeze(new Some(pData));
    }
    
    const none = crtNone();
    
    function crtFirstRemainder (first, remainder) {
        class FirstRemainder {
            constructor (first, remainder) {
                this.First = first;
                this.Remainder = remainder;
            }
        }
        return Object.freeze(new FirstRemainder(first, remainder));
    }
    
    function getFirstChars (str) {
        let len = str.length;
    
        if (len > 1) {
            return crtSome(crtFirstRemainder(str.charAt(0), str.slice(1)));
        }else if (len === 1) {
            return crtSome(crtFirstRemainder(str.charAt(0), ''));
        }else {
            return none;
        }
    }
    
    const trie = {};
    
    function add (trie, str) {
        const chars = getFirstChars(str);
    
        if (chars.isSome) {
            const first = chars.bindIt(d => d.First);
            const remainder = chars.bindIt(d => d.Remainder);
            if ((first) in trie) {
                add(trie[first], remainder);
            }else {
                let newTrie = {};
                trie[first] = newTrie;
                add(newTrie, remainder);
            }
        }
    }
    
    function display (trie) {
        for (let elem in trie) {
            console.log(elem);
            display(trie[elem]);
        }
    }
    
    function find(trie, str) {
        const chars = getFirstChars(str);
    
        if (chars.isSome) {
            const first = chars.bindIt(d => d.First);
            const remainder = chars.bindIt(d => d.Remainder);
            if ((first) in trie) {
                return find(trie[first], remainder);
            }else {
                return crtNone();
            }
        }else {
            return crtSome(trie);
        }
    }
    
    function strings (trie) {
        let arr = [];
    
        function strAux (trie, str) {
            for (const elem in trie) {
                strAux(trie[elem], str + elem);
            }
            if (Object.keys(trie).length === 0) {
                arr.push(str);
            }
        }
    
        strAux(trie, "");
        return arr;
    }
    
    add (trie, "G4143\n");
    add (trie, "This is the first\n");
    add (trie, "This is the second\n");
    add (trie, "This is the third\n");
    add (trie, "This is the fourth\n");
    add (trie, "Good job getting here\n");
    add (trie, "Here it ends...\n");
    
    
    console.log(trie);
    
    display(trie);
    
    const ans = find(trie, "This is the ");
    
    console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`);
    
    if (ans.isSome) {
        ans.bindIt(d => display(d));
    }else {
        console.log("Ooops. Didn't find anything!");
    }
    
    console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`);
    
    const sArr = strings(trie);
    
    for (const i in sArr) {
        console.log(sArr[i]);
    }
    
     
  9. Thesgtluca

    Thesgtluca Junior Member

    Joined:
    Apr 16, 2013
    Messages:
    123
    Likes Received:
    14
    Take a look at javascript path on pluralsight. Their monthly subscription is of 25$ ( I may be wrong ), but you can access a wide variety of tutorials of all programming languages.
     
  10. Bob Hensley

    Bob Hensley Newbie

    Joined:
    Nov 26, 2018
    Messages:
    19
    Likes Received:
    6
    Gender:
    Male
    Occupation:
    Full Stack Engineer (Web Developer)
    Team Treehouse and PluralSight are two of my favorite learning resources. I've been writing JavaScript for some 17 years, and as a member on these sites, I've checked out their JavaScript content from time to time (or due to it being prerequisites for others). And I've been happy with both. Easy to understand, but not so simple as to forego details where necessary.

    And it was linked above, but keep the MDN bookmarked. It is the bible of JavaScript web development.
     
  11. Arghs

    Arghs Jr. VIP Jr. VIP

    Joined:
    Dec 6, 2009
    Messages:
    117
    Likes Received:
    39
  12. superSoretin

    superSoretin Newbie

    Joined:
    Feb 25, 2020
    Messages:
    12
    Likes Received:
    1
    Gender:
    Male
    Thank you so much, man! works, even if it's just for a month, it's more than welcome. I guess I'll be checking out which tuts are useful and downloading them. Thanks again!