Types, Operators and Primitives
-
Upload
alexisabril -
Category
Technology
-
view
261 -
download
2
Transcript of Types, Operators and Primitives
Undefined undefined Null null Boolean true String "hello" Number 2 Object {name: "value"} Array [1,2,3] Date new Date() RegExp /.*/g, Function function(){}
Data Types
Primitive
Object
varnewassignment
deletemember
call
comparison
Operators
var foonew Foofoo = {bar: "a value"}foo.bar = valuedelete foo.barfoo.barfoo["bar"]bar()foo.bar()=====
var me = { name: {first: "justin"} },
name = me.name;
name = {first: "alexis"};
me.name.first // justin
var str = "hi";
Address Value
…. ….
x1001 call-object
x1002
x1003
x1004
…. ….
x2001
x2002
x2003
x2004
WINDOW
"hi"
Address Value
…. ….
x1001 call-object
x1002
x1003
x1004
…. ….
x2001 STRING
x2002 2
x2003 hi
x2004
"hi"
WINDOW
var str = "hi";
Address Value
…. ….
x1001 call-object
x1002
x1003
x1004
…. ….
x2001 STRING
x2002 2
x2003 hi
x2004
str "hi"
WINDOW
var str = "hi";
"hi"str
Address Value
…. ….
x1001 call-object
x1002 str
x1003 -----
x1004
…. ….
x2001 STRING
x2002 2
x2003 hi
x2004
WINDOW
var str = "hi";
var str = "hi";
Address Value
…. ….
x1001 call-object
x1002 str
x1003 2001
x1004
…. ….
x2001 STRING
x2002 2
x2003 hi
x2004
"hi"str
WINDOW
var obj = {};obj.txt = "hi";
Address Value
…. ….
x1001
x1002
x1003
…. ….
x2001
x2002
x2003
x2004
…. ….
x2101
x2102
x2103
WINDOW
var obj = {};obj.txt = "hi";
Address Value
…. ….
x1001 call-object
x1002
x1003
…. ….
x2001
x2002
x2003
x2004
…. ….
x2101
x2102
x2103
WINDOW
var obj = {};obj.txt = "hi";
Address Value
…. ….
x1001 call-object
x1002
x1003
…. ….
x2001 OBJECT
x2002 0
x2003
x2004
…. ….
x2101
x2102
x2103
WINDOW
var obj = {};obj.txt = "hi";
Address Value
…. ….
x1001 call-object
x1002 obj
x1003 -----
…. ….
x2001 OBJECT
x2002 0
x2003
x2004
…. ….
x2101
x2102
x2103
obj
WINDOW
var obj = {};obj.txt = "hi";
Address Value
…. ….
x1001 call-object
x1002 obj
x1003 -----
…. ….
x2001 OBJECT
x2002 0
x2003
x2004
…. ….
x2101
x2102
x2103
obj
WINDOW
var obj = {};obj.txt = "hi";
Address Value
…. ….
x1001 call-object
x1002 obj
x1003 x2001
…. ….
x2001 OBJECT
x2002 0
x2003
x2004
…. ….
x2101
x2102
x2103
"hi"
obj
WINDOW
var obj = {};obj.txt = "hi";
Address Value
…. ….
x1001 call-object
x1002 obj
x1003 x2001
…. ….
x2001 OBJECT
x2002 0
x2003
x2004
…. ….
x2101 STRING
x2102 2
x2103 hi
"hi"
obj
txt
WINDOW
var obj = {};obj.txt = "hi";
"hi"
obj
txt
Address Value
…. ….
x1001 call-object
x1002 obj
x1003 x2001
…. ….
x2001 OBJECT
x2002 1
x2003 txt
x2004 x2101
…. ….
x2101 STRING
x2102 2
x2103 hi
WINDOW
delete
var me = { name: { first:"justin" } }, name = me.name;
delete me.name;
name.first //-> "Justin"
WINDOW
name
name
"justin"
me
first
typeof
Type Result
Undefined "undefined"
Null "object"
Boolean "boolean"
Number "number"
NaN "number"
String "string"
Function "function"
Array "object"
Any other object
"object"
Summary
Variables are put in a call object.
var me;
= sets a variable or property to point somewhere in memory.
me = {};me.age = 30;
WINDOW
me
30
age
var me = { name: { first:"justin" } }, name = me.name;
name = { first:"alexis"};
me.name.first
Understanding
WINDOW
name
"alexis"first
name
"justin"
me
first