UNPKG

agentscript

Version:

AgentScript Model in Model/View architecture

73 lines (38 loc) 3.33 kB
<!-- # JavaScript --> AgentScript runs in the browser using the JavaScript language which has a fascinating history, having been introduced for the Netscape server in the mid 1990's. Here's a [JavaScript TimeLine](https://www.w3schools.com/js/js_history.asp) There are _LOTS_ of resources for learning JavaScript. You can find several books, too many to list here, but we'll show one on-line book below. And there are several tutorials and videos to use, just google _javascript tutorial_ for them. ## JavaScript in 14 Minutes One of the best tutorials for the absolute beginner is [JavaScript in 14 Minutes](https://jgthms.com/javascript-in-14-minutes). It uses the browser's developer console. It will detect your OS and default browser. I use Chrome but it supports them all. ![Image](/config/cleantheme/static/JS14Min1.jpg) Clicking on "get started" results in: ![Image](/config/cleantheme/static/DevConsole3.jpg) Click on "Copy to clipboard" above, then open a new tab, and typing the keys suggested above, "option+command+J" for me, gives: ![Image](/config/cleantheme/static/DevConsole2.jpg) Finally, paste the clipboard into the console, next to the ">". This results in: ![Image](/config/cleantheme/static/DevConsole4.jpg) Try typing simple JavaScript values like "1 + 2" and "Math.PI" in the console. ## Eloquent Javascript [Eloquent Javascript](https://eloquentjavascript.net/) is a much loved free online book which has a [javascript sandbox](https://eloquentjavascript.net/code/) for running every example in the book. ![Image](/config/cleantheme/static/Eloquent.jpg) Here is an [example for chapter 2](https://eloquentjavascript.net/code/#2.1). To see their solution, click "look at the solution" then "run code" buttons. ## Modern Javascript Also there is a complete, easy to use reference, ["Modern JavaScript"](https://javascript.info/). Rather than simply defining each primitive, it gives complete examples of them. ![Image](/config/cleantheme/static/Modern1.jpg) ![Image](/config/cleantheme/static/Modern2.jpg) Here is an [example for Strings](https://javascript.info/string). Rather than a dry definition of what a string is, it has a nice set of examples of the three string formats, along with methods strings supply. ## MDN Finally there's the Mozilla Developer Network [MDN](https://developer.mozilla.org/) ![Image](/config/cleantheme/static/MDN1.jpg) It is _the reference_ for all things browser: HTML, CSS and JavaScript. The [JavaScript section](https://developer.mozilla.org/en-US/docs/Web/JavaScript) is quite good, and you can search for any JavaScript primitive easily. ![Image](/config/cleantheme/static/MDN2.jpg) ## Writing simple JavaScript With all these resources, you might ask: how do I actually write JavaScript? The easiest way is simple: use the browser's Developer Tools. Lets try it. Open a new Browser tab. Then open the Developer Console. For Chrome, use "View > Developer > JavaScript Console" Menu, or the "Cmd-Option-J" keyboard shortcut. For others, use the help menu, typing "dev" should find it. (See the Browser tutorial for more) You can click-drag the console menu bar to make it larger. ![Image](/config/cleantheme/static/DevConsole2.jpg) Now you can write simple JavaScript tests. ![Image](/config/cleantheme/static/DevConsoleCode.jpg)