1.1 Core JavaScript

Source: Internet
Author: User

This was a tour of the JavaScript language, and also a tour of part I of the book. After this introductory chapter, we dive to JavaScript at the lowest level:chapter 2, Lexical Structure, explains thing s like JavaScript comments, semicolons, and the Unicode character set.

Chapter 3, Types, Values, and Variable, starts to get more Interesting:it explains JavaScript variables and the Values yo U can assign to those variables. Here's some sample code to illustrate the highlights of those the chapters:

Anything thing following double slashes is an english-language comment.

Read The comments Carefully:they explain the JavaScript code.

Variable is a symbolic name for a value.

Variables is declared with the VAR keyword:

var x; Declare a variable named x.

Values can be assigned to variables with a = sign

x = 0; Now the variable x has the value 0

X//=>0:A variable evaluates to its value.

JavaScript supports several types of values

x = 1; Numbers.

x = 0.01; Just one number type for integers and reals.

x = "Hello World"; Strings of text in quotation marks.

x = ' JavaScript '; Single quote marks also delimit strings.

x = true; Boolean values.

x = false; The other Boolean value.

x = null; Undefined is like null.

The other very important types the JavaScript programs can manipulate are objects and arrays. These is the subject of Chapter 6, Objects, and Chapter 7, Arrays, but they is so important thaht you'll see them many T IMEs before you reach those chapters.

JavaScript ' s most important data type is the object.

An object was a collection of name/value pairs, or a string to value map.

var book = {//Objects is enclosed in curly braces.

Topic: "JavaScript",//The property "topic" has value "JavaScript".

Fat:true//The property ' fat ' has value true.

}; The curly brace marks the end of object.

Access the properties of an object with. or []:

Book.topic//= "JavaScript"

Book["fat"]//= = True:another to access property values.

Book.author = "Flanagan"; Create new properties by assignment.

Book.contents = {}; {} is a empty object with no properties.

//

1.1 Core JavaScript

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.