已发布 / Published 2017-03-03T23:58:58+08:00

千天计划之第983天——notes of eloquent javascript||introduction

It is up to you to make the necessary effort.

图片


This is what I edit while reading the book slowly, namely it is the shorter one, hoping in this way you could save some time.


《Eloquent JavaScript》

Written by Marijn Haverbeke.

Hyperlink:http://eloquentjavascript.net/


Introduction




  • Getting computers to do what you want them to do. 

  • Two ways of bridging the communication gap between us, and computers.


    1. The first is to appeal to our sense of the physical world and build interfaces that mimic that world and allow us to manipulate shapes on a screen with our fingers. 

    2. The second , is teaching the machine a language.


      It is up to you to make the necessary effort. 


      1. do not jump to any conclusions about your own capabilities. 

      1.  just need to keep at it

      1. Take a break

      1.  reread some material,

      1. always make sure you read and understand the example programs and exercises.


       Learning is hard work, but everything you learn is yours and will make subsequent learning easier.


      CODE




      Programs looked something like this:

         

           `00110001 00000000 00000000 00110001 00000001 00000001 00110011     00000001 00000010 01010001 00001011 00000010 00100010 00000010     00001000 01000011 00000001 00000000 01000001 00000001 00000001     00010000 00000010 00000000 01100010 00000000 00000000`


      That is a program to add the numbers from 1 to 10 together and print out the result: 1 + 2 + ... + 10 = 55.


      Each line of the previous program contains a single instruction. It could be written in English like this:


      Store the number 0 in memory location 0.

      Store the number 1 in memory location 1.

      Store the value of memory location 1 in memory location 2.

      Subtract the number 11 from the value in memory location 2.

      If the value in memory location 2 is the number 0,  continue with instruction9

      Add the value of memory location 1 to memory location 0.

      Add the number 1 to the value of memory location 1.

      Continue with instruction 3.


      It might help to use names instead of numbers for the instructions and memory locations.

      1.  Set “total” to 0.  

      1.  Set “count” to 1. 

      1.  [loop]  

      1.  Set “compare” to “count”.  

      1.  Subtract 11 from “compare”.  

      1.  If “compare” is zero, continue at [end].  

      1.  Add “count” to “total”.  

      1.  Add 1 to “count”.  

      1.  Continue at [loop]. 

      1.  [end]  

      1.  Output “total”.


      Here is the same program in JavaScript:

      var total = 0, count = 1;

      while (count <= 10) {

        total += count;

        count += 1;

      }

      console.log(total);

      // → 55



      What is JavaScript?




      JavaScript was introduced in 1995 as a way to add programs to web pages in the Netscape Navigator browser.


      It is important to note that JavaScript has almost nothing to do with the programming language named Java. The similar name was inspired by marketing considerations, rather than good judgment. When JavaScript was being introduced, the Java language was being heavily marketed and was gaining popularity.


      JavaScript is ridiculously liberal in what it allows. The idea behind this design was that it would make programming in JavaScript easier for beginners. In actuality, it mostly makes finding problems in your programs harder because the system will not point them out to you.


      Code is the text that makes up programs.In my experience, reading code and writing code are indispensable parts of learning to program, so try to not just glance over the examples. Read them attentively and understand them. Don’t assume you understand them until you’ve actually written a working solution.


      The sandbox on the website provides links to Zip files containing all of the scripts and data files necessary to run the code for a given chapter.


      Hyyperlink of sandbox:http://eloquentjavascript.net/code/


      Overview of this book




      This book contains roughly three parts. 

      The first 11 chapters discuss the JavaScript language itself. 

      The next eight chapters are about web browsers and the way JavaScript is used to program them. 

      Finally, two chapters are devoted to Node.js, another environment to program JavaScript in.


      Good luck!


      And Morning Reading can not be uploaded here. So today there is not one.