Getting Started with JavaScript

Source: Internet
Author: User

First, the origin of JavaScript

JavaScript is a web technology, originally named LiveScript, which is a scripting language developed by Netscape to extend the functionality of basic HTML to replace complex CGI programs to process Web page form information and add dynamic effects to Web pages. When Java appears. Netscape developed a new scripting language with Sun, whose syntax is very similar to Java, so named: Javascript.

What is ECMA?

It was decided by Microsoft,netscape (Netscape) and other scripting language vendors to set up an international organization named ECMA, which was specifically designed for scripting language standards, and the ECMA-developed scripting language was called ECMAScript.

Note: All JavaScript complies with the ECMA standard. As if the Html4.0 Web page Header declaration conforms to the specifications.

Second, the JavaScript variable

(1) Variables in JavaScript are data types that are modified by the Var keyword, such as:

var x = 100;

var str= "This is my first step in learning JavaScript."

(2) Define rules for variables:

1: The first letter of the variable must begin with a letter, an underscore (_), and a dollar sign ($).

such as: var $$ = "42.5"; var test = 123; var _test = 46;

2: Variable name definitions must be meaningful.

Third, JavaScript data types

JavaScript data types: String, number, Boolean, array, object, Null, Undefined

Such as:

var x = 100;//Number

var str = "I am a string type";//String

var flag = true;//Boolean value

var money = 42.5;//Number

var STR3 = "Why add quotation marks";

var nullfalg = null;//null (NULL);

var arr = [];//array

var arr2 = new Array ();//Array

var obj = {};//Object

var obj2 = new Object ();//Object

var unde = undefined;//undefined

Use typeof to obtain the corresponding data type such as:

document.write ("x data type is:" +typeof x);

Four, JavaScript operators

(1) Commonly used JavaScript operators: add: +, minus:-, multiply: *, except:/, remainder:%, + +: Increment 、--: Decrement.

var x = 100;

var y = 22;

var z = x + y;//122

var k = x-y;//78

var c = x * y;//2200

var m = x/y;//4.545 (floating point)

var o = x% Y;//12

Digital conversions

var kk = parseint (m);//integer

var ff = parsefloat (4);//floating point

Increment and decrement conversions

var cc = 99;

++cc;//equivalent: CC = CC +1;

cc++;//equivalent to CC = CC + 1;

cc--;//equivalent to CC = CC-1;

--cc;//equivalent to CC = CC-1;

Alert (cc);//98

(2) JavaScript comparison operators

Greater than: > Greater than or equal: >= less than:< less than equals: <=

equals: = = value comparison is all equal to: = = =: Value and type comparison not equal to:! =

If two numbers are compared, the return type is: Boolean (true/false) such as:

var k = 1 > 2;

Alert (typeof K);

var c = 5 < 100;

alert (c);//true

var cc = 100<=100;

Alert (cc);//true

Explanation of all equals: the comparison of values is also a comparison of data types such as:

var = "strn";//--->string

var num = 100;//--->number

Alert (strn = = num);//--->true

Alert (strn = = num);//--->false

Written in the end: A standard for the ECMA JavaScript, the variable naming rules in JavaScript must be followed: the first letter must begin with a letter, an underscore (_), and a dollar sign ($). And to know how to get the corresponding data type through typeof. I think: learning is in the continuous summary and sharing, only so that your learning ability will be a good upgrade.

The source of this article: http://www.duanliang920.com/learn/web/tx/272.html

Getting Started with JavaScript

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.