please dont rip this site

JavaScript Tutorial Basics

JavaScript is a programming language: A way for humans to order computers around. A human who has become a "programmer" can order computers to do useful things for themselves and others. Really good programmers write new languages which become widely used.1. Today, JavaScript is called ECMAScript^ and runs in the V8 engine^ in Chrome^, Node.JS^ and now Microsoft Edge, WebKit^ / Nitro in Apple's Safari^, and SpiderMonkey^ in Firefox^.

Not Java: JavaScript has nothing to do with Java. 1 It's more closely related to ( LISP ), C, and Pascal.

Syntax: Like any language, JavaScript has a "syntax" you have to follow. When Brendan Eich1 wrote the language (in only 10 days!1) he was attempting to build something that could understand the idea you are trying to type in and then turn it into code for the computer. There are many (many) different ways to express the same idea in human languages. He didn't have time to figure out every way you could mess up typing something or every way you could express your idea. Syntax is like grammar in human languages; you may understand what you said, and your best friend may understand you, but you have to explain what you mean in a grammar Brendan's mind understood so his JavaScript language program can translate it to the computer.

Statements: Each line, or part of a line terminated by a ";" is a statement. These are the "sentences" of JavaScript; they express one basic idea per line. Examples:

There are a zillion possible statements, but only a few core words from which most are built. Good IDEs (Integrated Development Environments) can help you figure out what words are available by "hinting" them as you type:

Keywords: The words JavaScript knows. These are the entries in the dictionary of JavaScript. Here are most of the common JavaScript Keywords:
break case catch const do else eval false finally for function if in isNaN length let Math NaN name new return switch this throw true try typeof undefined var while with

This is not a complete list, and there are a bunch more related to documents in browsers and other special stuff. Notice some are standard english (if, false, true) and actually mean pretty much the same thing. Some are English words that don't mean the same thing (for, throw). Others are made up words (var, NaN). A few are two words crammed together (typeof, isNaN).

Also, case is important in JavaScript. Math (object prototype with math functions) is not math (doesn't exist). NaN is not nan or NAN. Syntax. Or else. (Use the IDE, Luke to hint which one to use). But even then, Document is not document and each is valid.

Variables: Names you give to pieces of the computers memory. They can be thought of as boxes in the memory closet, with names you use to label the front of the box, and values which are stored inside. JavaScript has specific types of boxes, of specific sizes, for specific uses. But it will switch from one sort of box to the next without telling you. For example, there is a type of box for numbers, and one for text (strings, messages, etc...). And it will select the type based on it's best guess. e.g.

var myvar = +"12" //this is now a number, and it's value is 12
var myvar = "12"*1 //this is now a number, and it's value is 12
var myvar = "12"+0 //this is now a string, and it's value is "120"

Objects: Almost everything in JavaScript is actually an object. e.g. myvar above is an object of type string or number. Objects are basically boxes of boxes. So there is a primative value like a string or number, but there are also other named boxes in the variable box and those boxes keep track of things like what type of box it is, how to do stuff to the value in the box, and so on. e.g.

myvar.length //tells us how long the value in myvar is. 
myvar.toString //contains a program that will convert myvars value to a string.
myvar.toString() //gives us the result of calling that program; the value as a string

Prototypes: Special objects are templates for making new objects with the new keyword. By convention, these "prototypical" objects are named with a single capital leter followed by lower case, and the objects created from them are all lower case. The document object has a prototype called Document. A more useful example is let my_array = new Array.

Functions: Functions take in parameters, then do stuff to them with a program and return values. Functions are also just objects like anything else, and can be stored in other objects, or have other objects or variables stored in them.

Methods:

Scope:

See also:


file: /Techref/language/java/script/basics.htm, 8KB, , updated: 2019/10/14 15:19, local time: 2019/12/7 02:16,
TOP NEW HELP FIND: 
35.172.217.40:LOG IN

 ©2019 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE! / 

<A HREF="http://techref.massmind.org/Techref/language/java/script/basics.htm"> JavaScript Basics</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to techref.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .