JavaScript for the front-end base

Source: Internet
Author: User
Tags arithmetic operators script tag

The history of JavaScript:

    • 1992Nombas developed C-minus (c--) embedded scripting language (originally bundled in Cenvi software), renamed Scriptease (client-executed language)
    • Netscape (Netscape) receives Nombase's idea (Brendan Eich) in its Netscape Navigator 2.0 product to develop a set of LiveScript scripting languages. Sun and Netscape are done together, and then renamed JavaScript.
    • Microsoft then emulated a JavaScript clone called JScript in IE3.0 's product.
    • ECMA (European Computer Manufacturing Association) defines the ECMA-262 specification in order to unify the three, from which the Web browser begins to work (albeit with varying degrees of success and failure) to ECMAScript as the basis for JavaScript implementation
    • ECMA-262 is the official name of the JavaScript standard

ECMAScript's detailed development history:

How Java is introduced:

  

some code in the 1.Script tag: < Script >      // write the JS code    here </ Script > 2. Introduction of additional JS files <  src= "Myscript.js"></Script>

JavaScript Language Specification:

1. Note: Single line comment://This is a single line comment

Multiline Comment:/* */* This is a multiline comment */

2. Terminator: The statements in JavaScript are to be (;) Terminator

JavaScript Language Basics:

1.JavaScript variable name can be used _, number, letter, $ composition, cannot start with a number

2. Declaring variables using var variable names; format declaration

var name = "KXL"; var age =; /* NOTE: Variable names are case-sensitive and can be used with camel-named */

JavaScript data type:

JavaScript has a dynamic type:

var x;                       // at this point x is Undefind var x=1;                   // at this point x is the number var x = "KXL";            // at this point,           x is a string

Numeric type: JavaScript does not differentiate between integral and floating-point types, there is only one numeric type

var a = 5.20; var b = 520; var c = 520e5;  // 52000000 var d = e-5;  // 0.0052

Common methods: (parseint converts variables to integers, Parsefolat converts variables to floating-point types)
parseint ("520") //Return 520
parseint ("AB") //Return Nan,nan property is a special value that represents a non-numeric number.
Parsefloat ("52.013") //Return 52.013

String:

var a = "Hello"var b = "world;var c = a + B; Console.log (c);  Get HelloWorld

Common Methods for strings:

Splicing strings generally use "+"

Boolean value type:

Different from python,true and false are lowercase

var true ; var false;

Array:

similar to the list in Python var a = [123, "ABC"];console.log (a[1]);  // output "ABC"

Common Methods for arrays:

To iterate over an element in an array:

var a = [ten, +, +];  for (var i=0;i<a.length;i++) {  console.log (i);}

null and undefined:

    • Undefined indicates that the declared variable is not initialized with the default value of undefined, and the function has no explicit return value that is returned undefined
    • Null indicates that the value does not exist

Undefined indicates that a variable was declared, but has not been assigned a value. Null declares that the variable is a null value

Type query:

typeof "ABC"  //  "string"typeofnull  //  "Object"typeof  true  //  "boolean"typeof//  "number" typeof is a unary operator (like ++,--,! ,-the unary operator), is not a function, nor is it a statement.

Operator:

Arithmetic operators:                           +-*/% + +- comparison operators:                            > >= < <=! = = = = = = =!== Note:1 = = "1"  //  True1 = = = "1"  //  false logical                            Operator:&& | |!  Assignment operator:                            = + = = *=/=

Process Control:

If-else:

var a=10; if (a>5) {    Console.log ("yes");    } Else {   Console.log ("no");}

If-else If-else:

var a = ten; if (A > 5) {  Console.log ("a > 5");} Else if (A < 5) {  Console.log ("A < 5");} Else {  Console.log ("a = 5");}

Switch

var New Date (). GetDay (); Switch (day) {  case 0:  console.log ("Sunday");     Break ;    Case 1:  console.log ("Monday");    Break ; default :  console.log ("...")}

For

 for (var i=0;i<10;i++) {  console.log (i);}

While

var i = 0;  while (I <) {  console.log (i);  I+ +;}

JavaScript for the front-end base

Related Article

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.