JavaScript_day02

day02 content

1. The reference data types
in JS addition to the above basic data types, all can be attributed to other types of reference data types.
1) Object Object
object is an object simulation of real life, the object of key pairs, through the use of braces to enclose all key-value pairs.
var dog = {name: 'Spot ', breed: 'Dalmatian'};
access object properties
dog.name
Dog [ 'name']
var Key = 'name'; Dog [Key]
2) Array Array
array is a special object containing a plurality of values, using a comma separated value and the value of all the values enclosed by brackets.
myNameArray = var [ 'Chris', 'Bob', 'Jim'];
var myNumberArray = [10,15,40];
. 3) Function A
function code execution unit is configured to achieve some special functions.
the Add function (A, B) {
return A + B;
}

review

Review
JS Basics
comment // single line comment / ** / multi-line comment
keywords
if else var continue break ...
reserved word
class interface Private protected ...
. 5 basic types of data
type undefined undefined
var A;
var A = undefined;
null null type
A null = var;
undefined derived from null
undefined // == null to true
Boolean type to true / to false
Number type integer, decimal, Infinity, NaN3
isNaN (10) to false //
isNaN (10 / 'A') to true //
isNaN ( NaN3) to true //
isFinite (10) to true //
isFinite (10/0) to false //
isFinite (Infinity) to false //
Number.MIN_VALUE
Number.MAX_VALUE
String type 'hello' "123"
reference data types
Object type
obj = {var
name: 'zhangsan',
Age: 12 is,
the sayHello: function () {},
Friends: [ 'Tom', 'Larry', 'Fairy'],
classes: {name: 'class'}
}
What when the attribute value may be something of an object, it can be any value as the attribute value, the value of the basic data types, reference value data type.

Distinguish between variable and value
var A = 'Lisi';
the console.log (A);
var obj2 = {
name: A,
Age:. 1
}
access object properties
obj2.name // Lisi
obj2.age. 1 //
obj2 [ 'name '] // Lisi
var = Key' Age ';
obj2 [Key] obj2 [' Age ']. 1 //
the array type
var arr = [1,2,4];
access array elements arr [0]

Operator
equal ==, second, only the comparison value, when the values are equal Returns true, false otherwise
returns true === congruent, third, and comparing the value of both comparison data type, data type and values are equal when otherwise, it returns false
! = unequal, only comparative value, values are not equal when returns true, otherwise it returns false
! == strict inequality, both comparison values and comparison of data types, data types or values are not equal when returns true false otherwise

Published 24 original articles · won praise 1 · views 408

Guess you like

Origin blog.csdn.net/hanmiao12345/article/details/105079583