FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
WebGLForOpenGLProgrammers/06javascript-objects.html at master · mortennobel/WebGLForOpenGLProgrammers · GitHub
mortennobel
/
WebGLForOpenGLProgrammers
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
8
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
WebGLForOpenGLProgrammers
/
06javascript-objects.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
88 lines (85 loc) · 4.38 KB
Breadcrumbs
WebGLForOpenGLProgrammers
/
06javascript-objects.html
Copy path
File metadata and controls
88 lines (85 loc) · 4.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<
html
>
<
head
>
<
meta
charset
="
utf-8
"
>
<
script
type
="
text/javascript
"
>
var
_gaq
=
_gaq
||
[
]
;
_gaq
.
push
(
[
'_setAccount'
,
'UA-26354413-1'
]
)
;
_gaq
.
push
(
[
'_setDomainName'
,
'kickjs.org'
]
)
;
_gaq
.
push
(
[
'_trackPageview'
]
)
;
(
function
(
)
{
var
ga
=
document
.
createElement
(
'script'
)
;
ga
.
type
=
'text/javascript'
;
ga
.
async
=
true
;
ga
.
src
=
(
'https:'
==
document
.
location
.
protocol
?
'https://ssl'
:
'http://www'
)
+
'.google-analytics.com/ga.js'
;
var
s
=
document
.
getElementsByTagName
(
'script'
)
[
0
]
;
s
.
parentNode
.
insertBefore
(
ga
,
s
)
;
}
)
(
)
;
</
script
>
<
link
rel
="
stylesheet
"
type
="
text/css
"
href
="
http://yui.yahooapis.com/combo?3.16.0/cssnormalize/cssnormalize-min.css&3.16.0/cssfonts/cssfonts-min.css&3.16.0/cssgrids/cssgrids-min.css&3.16.0/cssbase/cssbase-min.css&3.16.0/cssbutton/cssbutton-min.css
"
>
<
script
src
="
http://yui.yahooapis.com/3.16.0/build/yui/yui-min.js
"
>
</
script
>
<
link
href
='
http://fonts.googleapis.com/css?family=Coustard:400,900
'
rel
='
stylesheet
'
type
='
text/css
'
>
<
link
href
='
style.css
'
rel
='
stylesheet
'
type
='
text/css
'
>
<
title
>
WebGL for OpenGL Programmers
</
title
>
</
head
>
<
body
class
="
yui3-skin-sam
"
>
<
script
src
="
//cdn.jsdelivr.net/ace/1.1.3/min/ace.js
"
type
="
text/javascript
"
charset
="
utf-8
"
>
</
script
>
<
script
src
="
live_editor.js
"
type
="
text/javascript
"
charset
="
utf-8
"
>
</
script
>
<
script
src
="
navigator.js
"
type
="
text/javascript
"
charset
="
utf-8
"
>
</
script
>
<
div
id
="
page
"
>
<
header
>
</
header
>
<
article
class
="
content
"
>
<
div
id
="
wrapper
"
class
="
clearfix
"
>
<
div
id
="
singlecol
"
>
<
script
>
insertPageTitle
(
)
;
</
script
>
<
p
>
Objects are unordered sets of key-value pair. You can add or remove a key-value pair to and
from an object. Keys must be strings but values can be any JavaScript type. Objects are created
using
<
code
>
new Object()
</
code
>
,
<
code
>
new Fn()
</
code
>
(where
<
code
>
fn
</
code
>
is a function which
acts a constructor) and
<
code
>
{}
</
code
>
which is the short notation for object construction.
</
p
>
<
p
>
The
<
code
>
this
</
code
>
variable refers to the current object (or the global context when used outside
any object). In the code below pay special attention to how the same function
<
code
>
f
</
code
>
works
differently depending on whether it is used as a method on an object or a global function.
</
p
>
<
script
type
="
html-source/xxx
"
id
="
objects-example
"
>
var
o
=
new
Object
(
)
;
// var o = {}; // alternative
o
.
x
=
12
;
var
f
=
function
(
)
{
document
.
write
(
this
.
x
)
;
}
;
o
.
y
=
f
;
var
x
=
"global "
;
f
(
)
;
o
.
y
(
)
;
</
script
>
<
script
>
var
editor
=
new
LiveEditor
(
)
;
editor
.
data
=
'<scrip'
+
't>'
+
document
.
getElementById
(
'objects-example'
)
.
textContent
+
'</scrip'
+
't>'
;
editor
.
mode
=
"ace/mode/html"
;
editor
.
height
=
"195px"
;
editor
.
title
=
"Objects example"
;
editor
.
build
(
)
;
</
script
>
<
p
>
To delete a property from an object you use the
<
code
>
delete
</
code
>
operator (example
<
code
>
delete o.x;
</
code
>
).
</
p
>
<
p
>
JavaScript doesn't have classes but instead uses a concept called prototypes to define archetypes of
objects. Prototypes are useful when you want to create inheritance and can be used to mimic
traditional object-oriented class hierarchies.
</
p
>
<
ul
>
<
li
>
<
code
>
<
a
href
="
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
"
>
MDN: Object (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
</
a
>
</
code
>
</
li
>
<
li
>
<
code
>
<
a
href
="
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype
"
>
MDN: Prototype (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype)
</
a
>
</
code
>
</
li
>
</
ul
>
<
script
>
insertNavigator
(
)
;
</
script
>
</
div
>
</
div
>
</
article
>
</
div
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL