JavaScript learning Summary (1) -- JavaScript basics-javascript tips-js tutorial

Source: Internet
Author: User
This tutorial is suitable for beginners of javascript. A summary of the basic knowledge of javascript includes variables, basic types, and other knowledge points. You need to come and learn about it. 1. JavaScript Language Features

1.1 JavaScript is based on objects and events (dynamic)

It can directly respond to user or customer input without going through Web service programs. It responds to users in an event-driven manner. The event-driven action refers to the action produced by performing an operation on the home page. It is called an "Event ". For example, pressing the mouse, moving the window, and selecting a menu can be regarded as an event. When an event occurs, it may cause the corresponding event response.

1.2. JavaScript is cross-platform

JavaScript depends on the browser and has nothing to do with the operating system.

Ii. JavaScript Variables

2.1 define variables

When defining variables, all variables are represented by "var variable name". For example, var str; you can even omit the keyword var.

2.2. How do I determine the type of JavaScript variables?

The data type of variables in JavaScript is determined by the JS engine.

Var name = "lone wolf"; // name is string type var age =; // age is number type var flag = true; // flag is boolean type var email; // The email is only declared and no value is assigned. Therefore, it indicates the "undefined" type, that is, the name = cannot be determined. // The name is automatically changed to the number type.

2.3 use the typeof keyword to view the specific data type represented by the variable

The typeof operator has a parameter, that is, the variable or value to be checked. For example:

Var sTemp = "test string"; alert (typeof sTemp); // output "string" alert (typeof); // output "number"

When the typeof operator is called for a variable or value, one of the following values is returned:

Undefined-if the variable is of the Undefined type

Boolean-if the variable is of the Boolean Type

Number-if the variable is of the Number type

String-if the variable is of the String type

Object-if a variable is of the reference or Null type

Test code:

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.