Code Monkey home page Code Monkey logo

modern-javascript-explained-for-dinosaurs's Introduction

Modern-JavaScript-Explained-For-Dinosaurs

First part based on the article of Peter Jang, Modern JavaScript Explained For Dinosaurs

This repository will implement the article and link to the corresponding commits/branches. You should be able to read along the article and follow the corresponding branches.

To see the current master branch in action you need to run

npm i && npm start

The second part will add some more common development tools to the mix until you created your first real modern webapp.

Using JavaScript the “old-school” way

Branch: oldSchool

Showing how you do things with works with browser only, meaning no need for an httpd style server.

Some changes I added had been to override console.log to output to a div on the html.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>JavaScript Example</title>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.1/moment.min.js"></script>
    </head>
    <body>
        <h1>Hello from HTML!</h1>
        <div>Console.log here:</div>
        <div id="log"></div>
        <script>
            // https://stackoverflow.com/questions/20256760/javascript-console-log-to-html
            (function () {
                var logger = document.getElementById('log');
                console.log = function (message) {
                    if (typeof message == 'object') {
                        logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(message) : message) + '<br />';
                    } else {
                        logger.innerHTML += message + '<br />';
                    }
                }
            })();
        </script>
        <script src="index.js"></script>
    </body>
</html>

Using a JavaScript package manager (npm)

Branch: npm

No special changes besides the names.

Diff git diff 001_oldSchool..002_npm

Using a JavaScript module bundler (webpack)

Branch: webpack

No special changes besides adding bundle command to package.json. npm run bundle

Diff git diff 002_npm..003_webpack

Transpiling code for new language features (babel)

Branch: babel

No special changes.

Diff git diff 003_webpack..004_babel

Using a task runner (npm scripts)

Branch: scripts

No special changes besides to show how to link scripts in npm and implement "standard" target start and bundle.

Diff git diff 004_babel..005_scripts

Want more examples

part2 will explain how to add things like linting, testing many more.

modern-javascript-explained-for-dinosaurs's People

Contributors

scherler avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.