JS syntax and output variables, basic data types

<script>
// output Syntax: it is to print out the contents of the corresponding
 
// pop-up box will need to print the contents inside to put parentheses
alert('Hello Word!');
 
// print to the console log is recommended to use console.log () because the code is running console.log not interrupt and alert will interrupt the running code
console.log('Hello Word!');

// Dialog
prompt ( 'Do you like playing basketball?');
 
// confirmation box
confirm ( 'Are you sure you want to delete it?');
 
// print content on the page can be html tags
document.write('Hello Word!');

 
 
// Variables
// variable is a piece of open storage space to run named (simple understanding is a container, the container contained what the variable is what it means)
Rules and regulations // variables
// There are numbers, letters, underscores, $ accord composed, can not start with a number
// can not use keywords and reserved words, such as var, for and so on. . .
// case-sensitive, the same letter case are two different variables

//specification:
// names to be meaningful
// follow camel Nomenclature, the first letter lowercase, followed by the first letter capitalized eg: userName

// declare variables var variable name;
// I: was some;
// assignment sum = 10;
// declare variables and direct assignment, with more var sum = 10;
// You can then assign a number of variables declared directly after, or directly declare multiple variables and assign between use "," separated
// EG were a, b, c;
// a = 1;
// b = 2;
// c = 3;
// var a = 1, b = 2, c = 3; a plurality of variables and assignment statements directly


// simple data types
// numeric number
// number of all types of numbers are not separated in the js type integer number 1 and so the value of type is equal to 1.0

// string string
// no character type in the js. To represent a character, you can simply create a string that contains only one character
// add all the data quoted are single or double quotation marks can be of type string. Strings are immutable, once the string is created will never be able to change it
// string has a length property
//eg: "seven".length 是5
// string There are some ways
//eg: 'cat'.toUpperCase()=== 'CAT'

// Boolean boolean
// true false false true value only these two values, used for branch statement
// The following are listed as false value (false)
// false null undefined empty string '' NAN digital numbers 0
// Note: The string "false" is true

// null null reference
// represents an empty object is typically used to empty some objects

// undefined undefined
// declare variables only when there is no assignment will assign a default browser undefined

// NOTE: Use the typeof operator can return the data type of the current data
</script>

Guess you like

Origin www.cnblogs.com/lzfj/p/11456496.html